Is it possible to start the Eclipse JDT compiler from the command line, for example javac?

I would like to do some Java compilation from separate Java source files on the computer where Eclipse is installed. However, I do not have permission to install the full Java SDK on this computer.

I understand that Eclipse compiles through JDT without using javac .

Can I use the Eclipse compiler from the command line?

+7
command-line javac eclipse-jdt
source share
1 answer

A few minutes of searching, and I found this in the Eclipse Documentation under the section “Running the Batch Compiler”:

 java -jar org.eclipse.jdt.core_3.4.0<qualifier>.jar -classpath rt.jar A.java 

or

 java -jar ecj.jar -classpath rt.jar A.java 

I also found this Q / A on how to build an entire Eclipse project from the command line , which contains some of the same information, but since it doesn’t appear in my initial search. I leave this question open.

(And about 2 seconds before I click "Post your answer," John Skeet's answer came out.)


The exact syntax that worked for me (Sun JRE is on Windows PATH, Eclipse version is Galileo build 20100218-1602):

 java -jar "C:\Program Files\eclipse\plugins\org.eclipse.jdt.core_3.5.2.v_981_R35x.jar" test.java 

I omitted -classpath rt.jar and it still worked. Could not find file "ecj.jar" in this assembly.

It seems that the specific instructions for this are really changing from release to release, which is why caveat coder.

+7
source share

All Articles