Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Eclipse find javac to compile a project?

Tags:

java

eclipse

Here is what I have:

JAVA_HOME=C:\Software\Java\jdk1.5.0_12 (points to JDK 5.0)

In Eclipse "Installed Runtimes" I have: jre 1.5.0_12 (points to JRE 5.0) jre 1.6.0_3 (points to JRE 6.0) (this one is default)

I do not have "javac" on my PATH (i.e. I cannot run javac -version from command line if I am not in JDK/bin).

My project is set to use jre 1.6.0_3 and compiler's Compliance Level is set to 6.0.

Question is: how Eclipse is able to compile my project? Where it finds a compiler for 6.0? Moreover, is there a way to tell precisely which compiler (i.e. path to javac) is used by Eclipse?

P.S. OS XP SP2 if it is relevant P.P.S. I do not have any -vm set in eclipse.ini. In eclipse I see eclipse.vm=C:\Program Files\Java\jre6\bin\client\jvm.dll and it is still a JRE.

like image 813
Georgy Bolyuba Avatar asked Nov 28 '08 11:11

Georgy Bolyuba


People also ask

Where is javac compiler located?

The value that you want to add is most likely C:\Program Files\Java\jdk-14.0. 2\bin if you are installing "JDK 14.0. 2". This is the location where the Java compiler ('java.exe') was installed in your file system.

Does Eclipse use javac?

Eclipse Java compiler is an incremental Java builder The Java compiler built in Eclipse is a part of JDT Core component (JDT: Java Development Tool). An incremental compiler automatically compiles code when changes are detected.

Where are the .class files stored in eclipse?

The first thing you need to do is add a “Class Files” folder to the “Project 1” directory. You can do this via the File menu option. Once you are done, your Eclipse screen will look something like that below. Drag the file to the “Class Files” folder you just created in Eclipse.


3 Answers

Eclipse has the JDT which includes the incremental compiler so it does not need an external one unless that is your wish :)

like image 189
LenW Avatar answered Oct 23 '22 06:10

LenW


Eclipse has a list of installed JRE's under window->preferences->java->Installed JRE's. The one selected as the default will be the one included with Eclipse, but you can easily add any other JRE's from this same preference pane, and select any default you wish.

This will be the system wide default, which can be overridden on a project by project basis from the Build Path->Libraries tab. To change, select Add Library->JRE System Library and choose from your configured JRE's. Then remove the library for the default.

like image 38
Robin Avatar answered Oct 23 '22 05:10

Robin


Eclipse is shipped with an built-in compiler. You can use an external JDK, if you configure it in the preferences.

Edit: Thanks to André!

like image 26
guerda Avatar answered Oct 23 '22 05:10

guerda