24 easy steps to JEE 6 development with Eclipse

As some of you probably know I have a privilege to teach Java related stuff at Poznań University of Technology. During the lab sessions which I am leading we were going through configuration of Eclipse IDE to work with JEE 6. I am using Eclipse since I started to write in Java, some things are obvious for me. We wanted to work with Glassfish, Apache Maven and Subversion which are quite common tools, so it should be quite simple to force Eclipse to work with this setup. Let’s start.

  1. Download Eclipse IDE for Java EE Developers
  2. Unpack and run
  3. Now, I will have to install m2eclipse, I would like to use Eclipse Marketplace because it does not require knowledge about update sites for plugins. So, I choose “Help” and than “Eclipse Marketplace”.
  4. I am searching for m2eclipse… ok, there is something with Install button here [click].
  5. Accept the license agreement
  6. Confirm that I want to install unsigned jars
  7. Installation was sucessful, Eclipse is asking if I want to restart IDE – “ok, if you have to”.
  8. I know that I need also m2eclipse-extras for integration with Eclipse Web Tools Platform.
  9. I am choosing Eclipse Marketplace and searching for m2eclipse-extras – without luck.
  10. It seems that I need an update site for this. From Help menu I am choosing “Install new software”
  11. Starting to work with new Update Site for m2eclipse-extras
  12. I need to choose out of 4 bundles from that site. I cannot click “select all” because I don’t have Sublipse plugin installed, anyway who is using SVN nowadays? 😉
  13. After choosing right bundles it is time to accept license agreement
  14. Once again I need to confirm that I want to install unsigned jars
  15. Installation was sucessful, Eclipse is asking if I want to restart IDE – “ok, if you have to”.
  16. It is high time to import my project into workspace, choose File>Import>Import existing Maven project (but who knows maybe “Import existing project” would also work ;-))
  17. At this stage m2eclipse shows warning that my Eclipse is running on JRE not JDK and this may cause some problems
  18. To correct this I have to edit eclipse.ini and add “-vm” parameter with path to JDK (in separate lines – but everyone knows how .ini file works)
  19. Ok, now it is time for Glassfish, I choose Window>Preferences>Server Runtime and click on Add button
  20. There is no Glassfish here, so I choose to download additional server adapters.
  21. Ok, now I can choose out of four different Glassfish types (finally I will choose appropriate).
  22. During creation of new server runtime, I have to remember to point to glassfish-3.1/glassfish, (base glassfish-3.1 directory is not enough).
  23. After creation of new adapter, it should be possible to run imported application using Glassfish. It should be but…
  24. Eclipse says that in order to run Glassfish I need JDK – what the heck, I’ve just changed my eclipse.ini. Someone told me that I have to define new “Installed JRE” which is pointing to my JDK installation.

Only 24 easy steps – great!  😉

I’m not a huge fan of NetBeans but please take a look how NetBeans IDE deals with this issue.

  1. Download NetBeans (with Glassfish)
  2. Run NetBeans and Glassfish installer
  3. Run NetBeans IDE
  4. From File menu choose Open project
  5. From Tools menu choose Servers, ensure that Glassfish is in place. (This step is unfortunately necessary :(, without this NetBeans claims that there is no Glassfish defined – you just have to open dialog window, nothing more).
  6. Run Project

NetBeans will even launch Derby network server on its own if you use this DB in your project. I do not have nothing against Eclipse puzzles but it seems that it simply works!

I know why all this have to be done with Eclipse, but the question is who will bother with this if he can just launch Visual Studio 😉. In fact it is just a matter of reasonable defaults, is it really so hard? Maybe JEE is too new to get proper support in Eclipse?

  • Krzysiej

    Why not start with JBoss tools or STS, Eclipse is not really an end product.

    • I know that Eclipse is used as a platform for building other tool, but I cannot agree that Eclipse IDE is not an end product. Eclipse started as Java IDE and since its beggining is compared to other Java IDEs like NetBeans. If you are selling something as a product (Java IDE) it is a product 😉

  • ynka

    Just one remark to this great instruction set.
    I have been using Eclipse with Glassfish and Maven for some time and had this one annoying problem: I was not able to deploy Maven web projects through the Eclipse Glassfish adapter, as they where not recognized as webapps due to the lack of the WebContent folder. Of course I could deploy them using the command line or Glassfish console, but it bugged me. Finally I found a short discussion here: http://www.coderanch.com/t/508674/vc/Eclipse-Maven-Glassfish-work-together and fixed it (even though in my case the file is called org.eclipse.wst.common – depends on the facets I guess).

    I just thought that maybe it would be good to add a 25th step to your set 😉 Thanks, btw.

    • IMHO “m2eclipse Extras” should help here. Without having this properly configured in my Eclipse I had similar issue like yours. On m2eclipse website it is mentioned that this plugin deals with Eclipse WTP integration. Be sure to finish plugin installation process before importing maven project into Eclipse.

  • Pingback: stay dry » Automatically start JavaDB process in Eclipse()