Is it possible to run the Eclipse JDT compiler from the command line, like javac?
Asked Answered
K

1

8

I'd like to do some command-line Java compiling of individual Java source files on a machine that has Eclipse installed. However, I don't have permissions to install a full Java SDK on this machine.

I understand that Eclipse compiles through its JDT, not using javac.

Is is possible to use the Eclipse compiler from the command line?

Kollwitz answered 30/10, 2010 at 20:27 Comment(0)
K
7

A few more 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 didn't show up in my initial search I'm leaving this question open.

(And about 2 sec before I was going to click "Post Your Answer", Jon Skeet's reply popped up.)


The exact syntax that worked for me (Sun JRE is in the 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 the -classpath rt.jar and it still worked. Couldn't find the 'ecj.jar' file in this build.

It seems that the specific instructions for this do change from release to release, so caveat coder.

Kollwitz answered 30/10, 2010 at 20:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.