I noticed that Eclipse IDE (for Java, version 3.5.1) uses it's own java compiler(s), but I can't find how to change it. Is it even possible?
Maybe it's kinda trivial, but after many years of using IntelliJ IDEA I find returning to Eclipse a little bit awkward.
Thanks.
UPDATE: Since more detailed explanation was requested, I'm doing that.
So, recently I was helping out some fellow Java developer and noticed he is using Eclipse w/o Sun's JDK. Since company-wide we are using only Sun's JDKs, I found it rather strange.
It appeared that he has only Eclipse and no additional tools for compiling java code (like javac) are required. This is because Eclipse comes bundled with its own compiler (check this for more details).
By itself I find this feature quite nice, and I believe there were good reasons for that. But I would like all our company developers to use same compiler to generate java bytecode (.class files). And to run this in same JVMs. Just for sake of having as unified environment as possible and eliminating additional environment-specific issues. I have no problem with specifying JRE in Eclipse.
But I failed to find how to change default Java compiler to javac. On the other hand, my primary IDE IntelliJ IDEA allows do that (choose between javac, jikes or eclipse compilers). So I just wanted to know if same is possible in Eclipse or not.
Additionally:
What do you want to have? If you want to have the classes created by Sun compiler, you can build them using Ant. Eclipse uses its own compiler because Sun's compiler is not designed to be used in auto-compiled environment.
From the JDT website:
An incremental Java compiler. Implemented as an Eclipse builder, it is based on technology evolved from VisualAge for Java compiler. In particular, it allows to run and debug code which still contains unresolved errors.
Keep in mind that for the library itself, Eclipse will still use the one from Sun's compiler that can be set using the procedure explained by another answers (NimChimpsky and The Elite).
This is how to add your own JDK/JRE:
Windows
-> Preferences
menu.Java
-> Installed JREs
.Add
bitton (on the right), select Standard VM
, then a dialog box will appear with title Add JRE
.JRE home
: field, click on directory
button and browse to you JRE/JDK root folder. Once selected, it will auto-complete and click finish.Once you're done, go back to the Preferences
window, and tick the radio button of your added JRE/JDK to make it default.
Hope this helps.
While I've also looked for this, the only solution I found was to use Maven. With maven-compiler-plugin you can specify the compiler to use, and eclipse will delegate to it. I hope a similar trick can be done for Ant-based projects.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerId>javac</compilerId>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
</plugin>
dp4jmaventest is a working demo using this config.
Bug 341842 is an Eclipse feature request for such support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With