Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java for Eclipse compilation JRE issue

Tags:

java

eclipse

I use Mac OS, 10.6 and after recovering my back-up data, Eclipse stopped working. It gives me the following errors:

The container 'JRE System Library [JavaSE-1.6]' references non existing library '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar'       

Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'Proba'

I attempted to install again Java Development Kit (Help -> Install new software), and Eclipse actually installed it, but when I go to (Eclipse -> Preferences -> Java -> Installed JREs), I get error "Installed JRE location no longer exists. JRE will be removed. Reason: JRE removed", and installed JREs window is indeed empty. And the Java code still doesn't compile.

Solution: Go to: Eclipse -> Preferences -> Java -> Installed JREs -> Execution Environment and choose the JAVA SE 6 package (possibly JAVA SE 7 could work) and then choose the compatible JREs in the right-hand side.

Reload Eclipse.

like image 329
cerebrou Avatar asked Mar 18 '13 21:03

cerebrou


4 Answers

Two possibilities:

1. Update the Installed JRE
(Depending on the issue, one of the following will do)

  • Remove and Recreate the Installed JREs instance for the failing JVM.

    Eclipse -> Preferences -> Java -> Installed JRE

  • Install a new version of Java. (You can get it here), then Create a new instance using Eclipse's 'Installed JREs'. Set it as the default.

    Eclipse -> Preferences -> Java -> Installed JRE

(As you noted)
2. Update the Execution Environment such that it is compatible with the JRE.

Go to Eclipse -> Preferences -> Java -> Installed JREs -> Execution Environment and select a compatible env.

like image 172
cmd Avatar answered Oct 01 '22 06:10

cmd


Here is how to fix things up:

  1. Some versions in Mac like Lion does not come with a JDK; you can go and download one directly from http://connect.apple.com. Yes you need to sign up and login with your apple id. The download column is over on the right; and you should be able to find your way.

  2. The jdk is installed into a different location. This will result in IDEs (such as Eclipse) being unable to locate source code and javadocs.

  3. At the time of writing the JDK ended up here: /Library/Java/JavaVirtualMachines/1.6.0_31-b04-415.jdk/Contents/Home Please go ahead and have a look to confirm where your JDK ended up; this will no doubt change over time.

  4. Open up eclipse preferences and go to Java --> Installed JREs page

  5. Rather than use the "JVM Contents (MacOS X Default) we will need to use the above JDK location

  6. At the time of writing the Search button was not aware of the new JDK location; we we will need to click on the Add button and hunt it down ourselves.

  7. From the Add JRE wizard choose "MacOS X VM" for the JRE Type

  8. For the JRE Definition Page we need to fill in the following: JRE Home:/Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home

  9. The other fields will now auto fill, with the default JRE name being "Home". You can quickly correct this to something more meaningful: JRE name:System JDK

  10. Finish the wizard and return to the Installed JREs page

  11. Choose "System JDK" from the list You can now developer normally with javadocs correctly shown for for the base classes like java.lang.String, source code correctly shown when debugging.

like image 45
user3296594 Avatar answered Oct 01 '22 05:10

user3296594


The error above is simply saying that the Eclipse variable your JREs/JDKs have moved and the relevant variables defined within Eclipse point to locations that no longer exist now.

All you have to do is to point those variables to the new location, and the methods suggested above are good to go.

like image 41
Diferdin Avatar answered Oct 01 '22 06:10

Diferdin


4 Possible Alternatives:

  1. Re-configure the libs.
  2. Update the JRE.
  3. Update the Execution Environment.
  4. Check for MAC Updates. //Some versions of Mac does not have support for JDK by default. But you can re-configure this to solve your issue by using JDK rather than Mac Default variables.

One more thing which you can try is, to restore the Eclipse to Default state, i.e., re-install the version of Eclipse which you are using.(By the way, this worked for me, when I had a similar issue).

like image 28
D3X Avatar answered Oct 01 '22 06:10

D3X