Look, I know there’s all these new paradigms out there for programming applications that provide useful features and new technologies, but sometimes you still want to return to your roots and what you’re used to, just to see what it’s like.
I’ve been a Java programmer for a good part of a decade and a half and a lot has changed in that time. I’ve been a bit stagnant in taking advantage of the new areas of Java, so I thought it would be time to get a fresh setup up and running so that I can tinker and take a look to see if Java can indeed compete with the rest of the pack. But first, I need to get setup…
Love it or hate it, it’s a pretty robust platform that cant be ignored. I lean more towards the love it side, but it may be simply because I haven’t really used many other integrated IDEs for Java development. Once you have the servers hooked in, I think Eclipse can offer a good experience in terms of “just getting things done”. But the one warning is that you really want to have enough RAM… I mean lots. I’m comfortable with the 16GB I have, but I can see why people feel like it’s bloated (it is) when you only have 2GB of RAM to share with other apps.
Oh, and sometimes, it can feel downright ancient, but you can easily work around that… I hope.
I’m currently on Ubuntu 12.10, and the default Eclipse is 3.8. I no longer know if this is really considered Indigo or Juno, but all I know is that the newer 4.2 branch is horribly unstable and prone to a lot of crashes on Ubuntu. I tried it, but had to revert back to the default, which I guess is the default for a reason.
Anyway, getting it installed and running is pretty much as easy as visiting the software center. The fun starts when trying to get all the plugins and dependencies resolved. For this round, here’s my goal, installed specifically in this order since I had trouble when things got out of order:
- Install the Google Plugin for Android development and GWT (just to play around)
- Install GlassFish
- Install the “Web, XML, Java EE and OSGi Enterprise Development” tools
- Install Tomcat’s TomEE variation
- Install EclipseLink and JPA
- Install Maven plugin
- Install Git plugin
Now just getting them installed is a bit different from actually using them, but I just wanted to have some options setup now so that I can just try these out when I’m ready to play with them. So, onto the installation woes.
All these are installed via “Help -> Install New Software… : Add…” by adding a new plugin repository. You can actually add them all first then do each installation if you find that easier.
Preparation: Eclipse Update Site
For some strange reason, mine was missing the update side. So I added it in. Not sure if it was missing since Ubuntu is supposed to handle the updates or not, but I thought it’ll be good to have it there in case I wanted to browse it to add some extra plugins (like some of the ones below).
What tricked me up was that you can actually quickly see all the sites that are available to the Eclipse updater by using the dropdown arrow next to the filter box. For some reason I wasn’t seeing that and therefore wasn’t seeing the list of installable software populated. It would be nice to have it show everything by default, but understandably, they didn’t want to have an initial network hit fetching all that data, especially if you have a lot of sites.
First: Google Plugin
This will install things like the ADT Plugin for Android development (you still need to have the SDK installed, which you can find instructions for here). It also adds support to be able to play with GWT which is a nice addition. Not sure if I will, but it’s on the list of things I want to take a look at.
After a bit of experimenting, this plugin has to go first. If I install it later, it complained about some ant dependencies that just wouldn’t resolve themselves. The joy of dependency hell. But install it first and no problems.
The plugin comes in a 3.7 flavor also, but use the 4.2 variety. I think 3.8 is really almost the same as 4.2, just without the UI makeover.
GlassFish is basically the reference Java EE server produced by Oracle to support and showcase the standard. I figured it should be a good one to have and use, especially since it came as a complete package with the Apache Derby DB. Why not.
Once you load up the repository, you should see a “GlassFish Application Server” entry. Go through all the hoops, restart Eclipse, and end up back at the Install New Software section. I figured it’s pretty heavy duty and the dependency chain it installs will get a lot I’ll need later on installed.
Note: I’ve had the repository fail on me from time to time, so alternatively, you can use the Eclipse Marketplace to get Glassfish installed. There’s a good instructions set on Tech Juice.
Third: Web/XML/Java EE Tools
Repository: “Indigo Update Site” : http://download.eclipse.org/releases/indigo/
I also loaded from the Indigo Update Site: “Web, XML, Java EE and OSGi Enterprise Development” tools. But without the “PHP Development Tools (PDT) SDK Feature” and “Rich Ajax Platform (RAP) Tooling”. Not 100% sure why, but just followed the instructions from a Tomcat installation post. I figured they know what they’re doing and I’m not a PHP person anyway so no loss there.
Like GlassFish, TomEE is a full service stack. It’s basically Tomcat with the added modules to make it into a full Java EE stack.
This one you need to go download and install manually. We’re simply going to associate Eclipse with the freshly installed server. So, go download TomEE from Apache site (I got the Plus version). Then just “tar xfvz” it somewhere you like (I put it in /opt). It will need to be owned by the same user that will be initiating Eclipse in order to allow for file changes, so I just “chmod -R” to my user and group.
The instructions are nicely laid out on the site. If you already have a project, you can use the “Quick Start”, else it’s not too much of a hassle to do the “Advanced installation”. The only difference for me was that I couldn’t find the “Modules auto reload by default checkbox”. I changed the ports to +2 everything since I’m letting GlassFish run on port 8081 (a +1 from the default 8080). That way it wont interfere with my system’s default web server.
I opted to let Eclipse manage this instance of Tomcat so I set the preference to “Use Tomcat installation”.
When doing the server association, you can actually tell the system do go download Tomcat for you. I guess that way you can have a completely managed Tomcat instance via Eclipse, and all you would need to do is to add the additional libs/wars to turn it into a TomEE instance. I just opted to install my own separate instance and hook it in, but let me know if you’ve done otherwise.
Fourth.5: GlassFish configuration change
Just a note. I hate crappy directory layouts. And GlassFish creates a top level directory in your workspace for its server. However, once you install TomEE, it puts it’s server information in a “Servers” directory, like it should. So to fix this, I do a little cleanup to move the GlassFish server directory to the proper Server directory.
To do this, Open up the “Server” view, which should be showing a GlassFish server. Double click it and find the Domain Directory entry. Before hitting “Browse”, I copied the “glassfishdefaultserverlocalwhateverthislonguglynameis” directory to something like “Servers/GlassFish-184.108.40.206”. Once I have that, I hit “Browse” and simply selected that new directory and deleted the old one. All nice and clean.
Configuration Note: For some reason, I cant unlock the server port to edit it via the provided interface in Eclipse (when you double click on the GlassFish server). But you can do it manually by going to the GlassFish server directory (the one I changed to “Servers/GlassFish-220.127.116.11”) and editing the
config/domain.xml file and finding the entry for the
One note, anyone know how to change the default port on GlassFish? The Server and Admin Server Port entries are locked for me…
<network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
<network-listener port="8081" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
And that should do it. If you want to also run a stand alone version of GlassFish, you should probably go ahead and +1 all the other
<network-listener> ports so that there wont be any conflicts.
Fifth: EclipseLink and JPA
Repository: “EclipseLink” : http://download.eclipse.org/rt/eclipselink/updates/
EclipseLink allows you to easily use the Java Persistence APIs (JPA) to connect and pass objects to and from a data store. Well, so they say. I have yet to try it so we’ll see how easy it really is :).
Repository: “Maven” : http://download.eclipse.org/technology/m2e/releases/
Repository: “Maven Integration for WTP” : http://download.eclipse.org/m2e-wtp/releases/
Maven’s the super ugly cousin of npm, gem, other modern dependency package management system. But I guess it works once you get the hang of it. I have yet to get the hang of it, but would like to, hence I’m installing it.
You can find more detailed installation and project setup instructions on this companion post: Maven Setup.
Repository: “Git” : http://download.eclipse.org/egit/updates
Warning: Of course, the natural progression is to want to install the GitHub plugin. YMMV, but I couldn’t get it to work. In fact, it bricks my entire Eclipse installation and I had to clean out and reset my Eclipse back to the default and redo all the steps. I have no clue what went wrong, why, or how to fix it, but it’s borked me enough times to stay away from it for now.
At first when I tried to install the GitHub plugin (Site, Repository), it complained that I needed Mylyn installed. So I tried to install Mylyn (Site, Repository), but it complained that I needed Subclipse installed. So I installed Subclipse (Site, Repository), then Mylyn, then GitHub, then Eclipse would no longer restart. Had to nuke it all.
But do let me know if you can get it working…
So, speaking of nuking, sometimes, something will just go wrong and you need a fresh start. I’m not quite sure what to do about projects that got configured with important information, but I had a clean slate from the beginning, so I didn’t have to worry about relinking projects. If you need a clean Eclipse slate, because something like GitHub borked your installation, here’s some of the directories to clear out:
- Remove the version of eclipse that you are using from ~/.eclipse
- Remove the
Pretty easy, but again, be warned, if you already have established projects and you do this, the meta information about your project will be lost and you’ll have to re-import them back into Eclipse. I was on a clean slate so not too many worries for me.
I’ve noticed that at times I’ll get a message during startup complaining “An error has occurred. See the log for more details”. And that’s it. No more eclipse. The log is equally unhelpful complaining about some sort of OutOfMemory error.
I found this article which alleviated the problem by calling eclipse with the -clean flag:
Which seems to allow start up of Eclipse with no detrimental effects. No clue why, and neither did the author of the post know. But so long as it works, may as well leave that tidbit here.
Even though both GlassFish and TomEE are installed and runnable simultaneously, unfortunately you have to associate your project during creation time to one or the other. Which means you cant just plop a Glassfish project into TomEE and visa versa. But perhaps with some manual XML hacking, it can be switchable once you create it. I just haven’t gotten around to that level yet, and probably wont. But it’s good to have either available to play around with and see what’s going on.
Now that I’m all Java setup, I’ll probably start taking a look at some of the newer frameworks and see what they offer. Things like Spark, Britesnow, Play, Vaadin, Jetspeed, Jersey and even older ones like Hibernate and Spring… maybe. In the end, I want to see if modern Java development is up to snuff to compete with the newer frameworks.
As a preview, my next task would be to get a bit more of an understanding of JPA, which I’ll be experimenting with via this set of instructions. But experimenting early on, I’ve already run into a problem, so hopefully I can get around it (and I’m sure others) after a deeper dive.
Sometimes I cant tell Java is really the standout in terms of diversity and functionality or if I’m just used to it. Everything else feels pretty lacking in structure and organization. But I’ll see if there’s something out there that can compare. It is bloated, but there’s quite a lot out there for pretty much anything you want to do.