How to Get Eclipse to Use a Different Compiler Version for Java

Java compiler version and java version is different

Please check the following :

1) Check your path variable

2) Check JAVA_HOME variable

3)Delete the java,javaw and javaws .exe file from the system32 folder

changing eclipse's java compiler to jdk7

You need to upgrade to at least Eclipse Indigo SR1, which has been out for over a month. See also Eclipse announces full Java 7 support.

As evidence, here's a screen from my Indigo SR1 preferences:

Sample Image

And here's an example of executabele code snippet using diamond operator and ARM:

Sample Image

Which Java compiler is used by Eclipse?

Eclipse has its own Java compiler, which is called [JDT Core][1] (org.eclipse.jdt.core). The compiler itself is included in the org.eclipse.jdt.core plugin. Eclipse won't use any user installed JDK. Instead it uses its own JDT core to compile Java program due to the following primary reason:

The primary reason is that JDT core has the ability of incremental compilation, which means that it incrementally compiles changes in your code (this is also why Eclipse does not need a compilation button because it automatically compiles when changes are detected). But Oracle's JDK does not support incremental compilation.

Does Eclipse's JDT core compiler include a JRE?

  • No. JDT core is different from JDK. JDT core is a compiler not including a JRE (while JDK includes JRE). This is why we must specify installed JREs for Eclipse to start.

In summary, Eclipse uses its own JDT core as the Java compiler. The JDT core compiler does not have a JRE. So Eclipse requires user installed JRE to run the .class code.

References:

[1] JDT Plug-in Developer Guide, http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_compile.htm

[2] JDT Core Component, https://www.eclipse.org/jdt/core/

[3] How does Eclipse compile classes with only a JRE? How does Eclipse compile classes with only a JRE?

Have two JDK installed, how to switch the java compiler in Eclipse

Window > Prefrences > Java > Installed JREs

Compile class with different compiler compliance-version than the rest in Eclipse

You cannot do this in Eclipse, and I don't believe what you are trying to achieve is a good idea.

Here's what you could do instead:

  1. Change the code of this Java 8 class to something equivalent in Java 6 (if possible).
  2. Create a new project with this single class, and compile it with Java 8 compliance level. Specify this new jar file on the command line when launching your application, and it should do the trick.
  3. Have 2 different versions of your application (one that is Java 8 compliant, and the other being Java 6 compliant), and launch the correct one based on the Java version available on the system.

I'm not totally sure if that second option would work simply by putting the jar file in the classpath in the cases where your program is executed using a Java 6 JRE. You might have to do some class loader trickery if it fails to start.

Eclipse - compile and run with different Java version

go with right mouse button on your project->properties->java compiler

ther you can enable "Enable project specific settings" and choose an own compiler java version

How can I find the version of the Eclipse Java compiler (JDT)?

There isn't really a separate version for the ECJ compiler.

The standalone download of ECJ available on the Eclipse Project page is just numbered to match the Eclipse release (so 4.6 for the current Eclipse Neon release).

The compiler itself is included in the org.eclipse.jdt.core plugin which has its own version (currently 3.12.0)



Related Topics



Leave a reply



Submit