Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Eclipse compile classes with only a JRE?

I need to batch a compilation with a special JRE which has been "customized".

Eclipse is able to compile the classes with this JRE, but I need to make a build script outside of Eclipse.

What is the method used by Eclipse to generate the .class files without a JDK?

like image 378
glmxndr Avatar asked Oct 29 '09 08:10

glmxndr


People also ask

How does Eclipse compile Java code?

Eclipse Java compiler is an incremental Java builderAn incremental compiler automatically compiles code when changes are detected. It doesn't compile the whole project's code. It compiles only the changes you have made (incrementally), giving fast response to programmers.

Which Java compiler does Eclipse use?

In summary, Eclipse uses its own JDT core as the Java compiler. The JDT core compiler does not have a JRE. So Eclipse requires user installed JRE to run the . class code.


1 Answers

Eclipse comes with its own compiler for the following reasons:

  • Incremental compilation (can compile just the changed parts of the project which can mean more than the amount of files you just saved, for example, when you changed some global)
  • The Eclipse compiler can create a class file even when the code contains errors. This allows to run the project even though not everything compiles.
  • The compiler provides Eclipse with an AST so it can do all kinds of fancy stuff (like the outline, show you all the places where the variable under the cursor is used, etc) at no extra cost (i.e. it doesn't have to run the compiler and another parser).
like image 114
Aaron Digulla Avatar answered Sep 22 '22 01:09

Aaron Digulla