### Use Eclipse Batch Compiler

Eclipse has a batch compiler, to compile classes.
Read here:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_batch_compiler.htm
To use you need the compiler ecj.jar. See previous link on how to get.
Ensure to add to your path or copy into the project folder.
Example usage from the DOS command line
Java Code
File:
xcalc.java
Code:
public class xcalc {
public int xadd(int a, int b){
return a + b;
}
public int xmultiply(int a, int b){
return a * b;
}
public double xdivide(int a, int b){
if (b == 0) throw new ArithmeticException();
return a / b;
}
}
Compile from the command line - No Error
java -jar ecj-4.4.jar -classpath rt.jar xcalc.java -log log.txt
Result:
Java Class:
xcalc.class
Log File:
Log.txt
# 01.08.14 10:36:49 MESZ
# Eclipse Compiler for Java(TM) v20140604-1726, 3.10.0, Copyright IBM Corp 2000, 2013. All rights reserved.
Compile from the command line - with Error
Code changed with Error:
public int xadd(int a, int b){
return a + b;
}
Compile:
java -jar ecj-4.4.jar -classpath rt.jar xcalc.java -log log.txt
Result Log File:
# 01.08.14 10:45:18 MESZ
# Eclipse Compiler for Java(TM) v20140604-1726, 3.10.0, Copyright IBM Corp 2000, 2013. All rights reserved.
----------
1. ERROR in C:\Daten\b4j\samples\Compiler\compilertest\Objects\xcalc.java (at line 4)
Xreturn a + b;
^^^^^^^
Syntax error on token "Xreturn", return expected
----------
1 problem (1 error)

Changed: , Category: Java, File: T6C205M1509.htm, ID: 1509