Eclipse – Understand all the Java versions

I can still clearly remember the early days in my career while I was trying to learn Java as a Python developer. One big barrier for me was getting the development environment to set up properly. Just the Java itself was not a good experience since I was using the company laptop, and the IT really cannot catch up with the latest Java version, in another way, just upgrading the laptop Java version will screw up tons of services. Then there is a tool Maven which is supposed to help you ease some of the pain of solving for dependencies, however, getting Maven up and running on Mac, set up all the environment variables and even work with m2e plugin in Eclipse was such a PITA without a mentor. Then I head down the route of Python…

Recently I am trying to pick up how to develop enterprise level RESTful API using Java and it gave me another opportunity to learn Java again, this time, I am more patient.

I am following this book which it has a workbook that you can follow and try the code.

First, I used the Eclipse installer to download both the Java EE and Java eclipse.

The Eclipse Java EE IDE for Web developers have tons of tools, plugins built in that dramatically save me time setting up the environment. And the version is Mars.1 Release(4.5.1). I have heard people complaining about Mars and some even suggest go back to Luna.. but I am comfortable so far.

Here is the Github repo where the source code sits. After I downloaded the repo, unzip and use the import maven feature into Eclipse, the projects looked fine with a few warnings.

And it failed after I run as maven build.


I found this Q&A on stackoverflow saying that there Maven version that I am using is probably higher than the corresponding Java version. In which case, I either need to downgrade my Maven or upgrade my Java to make them work together. And I choose the later.

After some research, I realize the Java environment in Eclipse is not as easy as “set one Java_home”. As everyone can see from the screenshot, there are a few places indicate that even if I went to oracle’s website and downloaded the latest Java 8. 66, somehow Eclipse is using Java1.6 to compile my code.

  1. At the header part of the console, it says “<Terminated> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java (timestamp…)”
  2. In the project explorer, under the Libraries of the project, you can also see the project is using a JRE (Java Run Environment) System Library which is Java SE-1.6

Now it is just a matter of change that to Java SE -1.8?

First, lets review how many Java versions do I have in the end, here is a screen shots of two directories where OS level Java JRE and user installed Java environment is.


Here I have 1.6 JDK under the OS library, and 1.8 under the Library where I installed myself, two versions 65 vs 66.


In Eclipse Preference, there are two places where you can setup the default JRE to use when creating new projects:

Here I have selected Java 1.8 both in the compiler and installed JRE to make sure I am using Java 8 installed Java 6 from now on.

So we just solved the problem of configuring the latest Java JRE as the default Java JRE for Eclipse when new project is created, how about the one that error out, we still need to manually change it. BTW, I think when you import existing projects, Eclipse won’t be smart enough to use 1.8 which is what you have just setup, you might still need to manually setup the Java JRE to point to 1.8.

Screen Shot 2016-01-17 at 3.29.09 PM

Right click the project, and select the Properties for this project, navigate to the “Java Build Path” where we can see JRE SE 6, is still there which need to be first removed, and the click add Library and we should be able to select JRE SE 8.

Now, run the projects as Maven and it worked and successfully Build the whole project.

There was a small glitch where it failed when closing the Jetty server, but it got resolved by adding one extra dependency in the POM which is:


Screen Shot 2016-01-17 at 3.34.33 PM.png

In the end, there is a term that I want to highlight called project Facets. Facets define characteristics and requirements for Java EE projects and used as part of the runtime configuration. After I fixed the Java JRE project, that project somehow shows error in the project explorer where I cannot find any red mark anywhere in the code.

Screen Shot 2016-01-17 at 3.55.33 PM

Screen Shot 2016-01-17 at 3.53.52 PM

Project Java Facets need to be changed from 1.6 to 1.8

Then someone says I need to go to the project Facts in the project property to change from 1.6 as 1.8 and it stopped complaining.

Sorry, this whole post absolutely is a bit confusing if you have come across the problem yourself but I wish it will be helpful to the ones who ran into similar problems.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s