Eclipse Ee For Java Developers

Its pretty clear that the Eclipse IDE for Java provides an environment to develop and run Java code while the Eclipse IDE for Java EE supports enterprise applications. It means that you can use the servlets and JSP like technologies which are supported Eclipse IDE for Java EE. 8.7K views Sponsored by Coding Dojo. If you want to build Java EE applications, it's best to use Eclipse IDE for Java EE. It has editors from HTML to JSP/JSF, Javascript. It's rich for webapps development, and provide plugins and tools to develop Java EE applications easily (all bundled). Eclipse Classic is basically the full featured Eclipse without the Java EE part. Eclipse IDE for Enterprise Java Developers Eclipse offers collections of plugins-denominated Packages; each package is a collection of common plugins aimed for a particular development need.

  1. Eclipse Ide For Ee Java Developers
  2. Eclipse Ide
Tutorials / Server Tutorials / Eclipse EEtutorialjavaservereclipse

So far we’ve been writing all of our code in a basic text editor, and compiling our servlet classes via the command prompt. It’s important to understand the basics of how a web app works: stuff like running the server (in Jetty, that’s the start.jar file), setting up web.xml, and writing and compiling servlet classes and copying them into the WEB-INF/classes directory.

But as our code gets more complicated, using an IDE like Eclipse will make our lives much easier.

This tutorial assumes you’re already familiar with Eclipse from the Eclipse tutorial, so I won’t spend a ton of time introducing ideas like workspaces and projects. Instead, this tutorial talks about using Eclipse to develop web apps.

Enterprise Edition

You might have seen stuff referred to as EE, as in Java EE or Eclipse EE. That EE stands for Enterprise Edition, which is basically just versions of Java and Eclipse that include tools for server development.

I think the term is a little outdated, because it dates back to a time when the only interactive websites that existed were owned by businesses: stuff like online stores. That’s where the term enterprise (which is just another word for business) comes from. Now interactive websites are all over the place, not just owned by businesses. But we’ve kept using the term EE to describe stuff used for developing interactive websites.

You’ve actually already been using Java EE. It’s the tools and .jar files that come with your Jetty server. When you add servlet-api-3.1.jar to your classpath so you can use the HttpServlet class, you’re using Java EE. When you use JSP, you’re using Jave EE. Java EE isn’t an alternative to regular old Java- it’s built on top of it.

Simlarly, Eclipse EE is a version of Eclipse that comes with a bunch of tools that make it easier to write server code. Remember how Eclipse let you compile and run a Java file just by pressing the play button? Eclipse EE lets you compile and run a server just by pressing the play button!

Do you already have Eclipse EE?

If you already have Eclipse, let’s check whether you already have the EE version. Open Eclipse, and then go to Help > About Eclipse. The window that pops up tells you which version you have.

  • Eclipse IDE for Java Developers means you have the standard edition, so you need to download Eclipse EE.
  • Eclipse Java EE IDE for Web Developers means you have the EE version, so you can skip the next step.

Download Eclipse EE

Go to the Eclipse download page and download the installer. When the installer launches, a dialog asks you which version to install. Choose Eclipse IDE for Java EE Developers:

Step through the installation process and then launch Eclipse EE. In the workspace chooser that pops up, I recommend creating a new workspace directory instead of reusing an existing workspace. If you see a welcome tab, you can close this it (and uncheck “Always show Welcome at startup” if you want). Finally, you should see something that looks like this:

This means that Eclipse EE is running. Now we can start creating servers and web apps!

Eclipse Jetty

To use Jetty from Eclipse, we’re going to install the Eclipse Jetty plugin.

Open the Eclipse Marketplace by going to Help > Eclipse Marketplace.., and then type Jetty in the search box. You should see a plugin called Eclipse Jetty:

Install Eclipse Jetty. You’ll have to accept its license and then click OK in a box warning you about installing software. You’ll also be asked to restart Eclipse. When it comes back up, you’re done!

New Project

Go to File > New > Project.. and in the dialog that pops up, go to Web > Dynamic Web Project and click Next.

On the next screen, give your project a name. The default settings for everything else should be okay.

You can click through the rest of the settings using the Next button, or you can just click the Finish button to accept the default changes.

You should now see your project in the Project Explorer tab.

It’s empty for now, but we can see how the project is organized:

  • Java Resources: This is where servlets and other Java classes will go.
  • JavaScript Resources: JavaScript files in your webpage will show up here so you can edit them.
  • WebContent: This is the top-level publically available directory. This is where static files go.
  • WEB-INF: Files in here are hidden from public access. This is where web.xml and other files you don’t want users to access directly will go.

You can ignore the other stuff for now. Also note that your Java classes will go inside the src directory under the JavaResources - you don’t have to compile them into the classes directory yourself anymore! We’ll see that in action in a second.

Servlet Classpath

One last thing we need to do is add the servlet API to our project’s classpath. This will give us access to Java EE classes like HttpServlet and HttpServletRequest. We did this using the -cp path/to/jetty/lib/servlet-api-3.1.jar when we were using the console. In Eclipse, we need to add that .jar file to our Java build path.

To do that, right-click your project, then go to Properties, and in the dialog that pops up go to the Java Build Path section. You should see this:

This shows the list of libraries on your classpath. To add the servlet API to the classpath, click the Add External JARs.. button, and then select the servlet-3.1.jar file in your Jetty directory. You should now see this:

Now we’re ready to write some code!

Writing Code

Let’s start by creating a servlet. Right-click the src directory, then go to the New menu, and select the Class option. Name your class HelloWorldServlet, and click the Finish button.

That should open up the Java editor. Enter this code into it:

This code creates a basic servlet that adds a message to the request and forwards it to a JSP file. Next, let’s create that JSP file. Right-click the WEB-INF directory, expand the New menu, and then select the JSP File option. Name the file HelloWorld.jsp and click the Finish button.

That opens up a JSP editor. You can delete any template code that’s automatically added, and enter this JSP code:

This JSP just displays the message using the EL ${} syntax.

Finally, let’s create a web.xml file that tells our server to map URLs to our servlet. Right-click the WEB-INF directory, expand the New menu, and then select the Other option. In the dialog that pops up, expand the XML directory and select the XML File option. Click Next, and then name your file web.xml and click Finish.

Jitsi 8x8 video meetings. That opens up the XML editor. If the Design tab is selected, switch to the Source tab. Enter this XML:

Your project should now look like this:

Running Jetty

Now that we have a web app project, we need to tell Eclipse to run it using Jetty. You only have to do this step once for each project you create.

Eclipse ide for ee java developers

With your project open, open the Run menu, and then click the Run Configurations.. option. In the dialog that pops up, select the Jetty Webapp tab, and then click the New button (it looks like a piece of paper with a plus sign) in the upper-left corner.

That opens up a configuration panel where you can change a bunch of settings. Here are the ones we care about now:

  • Context Path is the part of the URL after the domain. If you leave this as /, then your webapp will be at http://localhost:8080. If you change it to HelloWorld, your webapp will be at http://localhost:8080/HelloWorld/. Let’s change it to HelloWorld for now.
  • The Options tab allows you to specify which Jetty version to use. The default uses a Jetty server that comes with the Eclipse plugin, but let’s use the version of Jetty we already have. Select the Use Jetty at path radio button, and then click the External.. button and navigate to your Jetty directory.

Your run configuration should look like this:

You’re done! Click the Run button!

You should see some stuff print to the console in Eclipse. That means your server is running, and you can access your web app! Open a browser to http://localhost:8080/HelloWorld/index.html, and you should see this:

Try changing the value of message in the HelloWorldServlet class. Click the Stop button (it looks like a red square in the Console tab in Eclipse) to stop the server. Then click the Run button (it looks like a green play button towards the top of Eclipse) to run the server again. Refresh the page, and you should see the new message!

Summary

Eclipse gives you a bunch of cool features: it tells you about compiler error directly in the editor, it offers autocomplete and auto-fixing of code, and it makes it easier to compile your code and run a server.

But you don’t have to use Eclipse. You can stick with a basic text editor and the console if you want. And in fact, I think it’s really important to understand the basics of what’s going on behind the scenes (knowing how to run Jetty and how it’s finding web apps and mapping them to URLs). You could also use another IDE designed for writing code instead of Eclipse if you want.

No matter how you write code, the process is the same: you create a web.xml file that maps a URL to a servlet class, you create a servlet class that contains your logic, and you create JSP files that render your view, which can use static files in the visible directory. You then run the server and visit your web app in a browser. Eclipse just makes stuff like compiling and running a little simpler. There’s no magic!

Happy Coding is a community of folks just like you learning about coding.
Do you have a comment or question? Post it here!

Introduction

Eclipse is a great open-source Integrated Development Environment that supports a lot of languages.

Install a Java Development Kit

For JavaEE work, I currently prefer JaveSE.

  1. Browse to Oracle’s Java SE Development Kit downloads
  2. In the section titled Java SE Development Kit 9.0.1, read the license and, if you agree, click Accept License Agreement
  3. Still in that section, click on jdk-9.0.1_windows-x64_bin.exe (or the right download for your OS)
  4. Run the downloaded JDK installer, using Run As Administrator
  5. Add the Windows (or Linux) Environment Variable JAVA_HOME. Set it to the root folder of your newly-installed JDK, which for me is C:Program FilesJavajdk1.8.0_51
  6. If you are working behind a proxy, you have my sympathy. Set these additional Environment Variables
    1. HTTP_PROXY to your proxy server and port. Something of the form http://myproxy:911
    2. HTTPS_PROXY to the appropriate server and port. Something of the form http://myproxy:911
    3. NO_PROXY to a comma-separated (on Windows) list of sites that are not on a proxy. Something like localhost,*.mycorp.com

Eclipse Ide For Ee Java Developers

Install Eclipse Oxygen for Java EE

  1. Browse to Eclipse Downloads
  2. Click on the Download button under Get Eclipse Oxygen.
  3. On the resulting page, click on the Download button.
    1. Note: the width (32 bit or 64 bit) must match the width of your installed JDK. You installed jdk-9.0.1_windows-x64 above, so download the 64-bit Eclipse.
  4. Run the downloaded installer using Run as Administrator.
  5. Choose the version of Eclipse you wish to install. I prefer Eclipse IDE for Java EE developers for Java work.
  6. If the installation fails, try again with realtime virus scanning temporarily turned off. Remember to turn it on again when you’re done.

Configure Eclipse

Eclipse Ide

  1. If you are behind a proxy, set the Eclipse Proxies to match:
    1. Start Eclipse
    2. Select Window / Preferences
    3. Select General / Network Connections (that is, expand the General section and click on Network Connections)
    4. For Active Provider, select Manual. In my experience, Eclipse has never been able to use the Native OS proxy settings.
    5. Set HTTP to your proxy and port as when you set up Java. Something like http://myproxy and 911
    6. Set HTTPS to the appropriate server and port, as when you set up Java.
    7. If you have a SOCKS proxy, set it here.
      1. NOTE: If SOCKS proxy is checked, make sure to set the proxy to something. It seems that a checked but empty Eclipse SOCKS proxy gives Maven some issues.
    8. Click OK
    9. Create a folder named lib under your Eclipse root folder. Something like C:UsersYourLoginDocumentseclipselib Do this to avoid Tomcat server errors later on.