If you are new to Java development with Eclipse IDE, you may be surprised that Eclipse doesn’t use javac – the Java compiler provided by JDK. Instead, Eclipse implements its own Java compiler – based on the Java Language Specification (JLS). There are some good reasons that Eclipse makes use of its own Java compiler:

 

1. 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. It doesn’t compile the whole project’s code. It compiles only the changes you have made (incrementally), giving fast response to programmers.

In contrast, javac does not support incremental compilation. If Eclipse uses javac, programmers will experience slow response for changes they have made, which decreases productivity.

Eclipse Java compiler requires JRE to run compiled byte code, so a JRE is enough to use Eclipse IDE – JDK is not necessary.

 

2. Eclipse Java compiler allows customization of error and warning messages

Eclipse Java compiler may produce more warnings and errors than javac, which is useful for programmers. You can customize errors and warnings for various Java coding issues.

In Eclipse, go to Window > Preferences > Java > Compiler > Errors/Warnings – then you can see what you can customize:

customize errors warnings in eclipse



For example, if Value of local variable is not used, you can instruct the compiler to show an error, warning, info or ignore it.

 

3. Eclipse Java compiler allows slightly broken code to run

The incremental compiler in Eclipse allows to run a Java program even it still contains unresolved errors. For example, you have error in a method and you attempt to run the program, Eclipse will show a warning message like this:

run program with errors in eclipse

Click Proceed to run the program anyway. This feature is useful if the unresolved errors do not relate to the code you want to test.

 

4. Eclipse Java compiler vs. javac compiler

Since Eclipse Java compiler and javac compiler are different, they usually produce different error/warning message for the same issue. Consider this line of code:

int x = “20”;

In Eclipse, it will say:

Type mismatch: cannot convert from String to int

But javac will say:

error: incompatible types: String cannot be converted to int

However, both Eclipse Java compiler and javac implement the Java Language Specification (JLS), the bytecode they produce is almost the same. Except for some corner cases they may produce different bytecode or code compiles with Eclipse but not compiles with javac.

So via this post, I hope you understand why Eclipse uses its own Java compiler and the benefits.

Watch the video:

 

Other Eclipse Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#3John2021-02-21 16:47
Interestingly javac's and the Eclipse Compilers outputs aren't as identical as you'd expect or hope for. People should be aware that there are substantial quality issues affecting the output from javac. The JVM is able to filter out the majority of javac's verbose/redundant byte code.
Quote
#2Nam2020-04-07 09:06
This is a second comment for testing purpose only
Quote
#1Nam2020-04-07 08:39
This is a comment for testing purpose.
Quote