9

If I tell NetBeans (6.9) to compile on save, NetBeans warns me the compiled classes are not identical to classes compiled with JDK's compiler. The Java platform is set to "JDK 1.6" in the same dialog. Which compiler is used by NetBeans? Why doesn't NetBeans use the JDK compiler?

alt text http://img814.imageshack.us/img814/3449/compileonsave.png

Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
deamon
  • 89,107
  • 111
  • 320
  • 448
  • Can't you set NetBeans to use your installed SDK? Don't forget that NetBeans and Java are now owned by Oracle, so basically a NetBeans SDK is actually a java SDK. – Buhake Sindi Jul 29 '10 at 16:21

5 Answers5

5

Like Eclipse, Netbeans does not use standard javac so that it can offer incremental compilation and compilation of classes containing methods that have syntax errors.

Unlike Eclipse (which uses its own Eclipse Java Compiler), Netbeans actually uses the internal API of javac for compiling, syntax highlighting, and error detection. This is a nice advantage, in that Netbeans is able to handle all of the latest Java language features and faithfully reproduces any nuances or bugs of javac's behavior.

sources:

Aleksandr Dubinsky
  • 22,436
  • 15
  • 82
  • 99
3

Why doesn't NetBeans use the JDK compiler?

Quite simply because Sun's javac is intended to be used for batch-based compilation from the command line of definitively valid files. Whereas NetBeans (and other IDEs) do incremental compilation as you type, and quite often have additional features such as creating classes for invalid files (so you can run methodA if methodB has a syntax error in, etc.).

Different tools for different requirements.

Andrzej Doyle
  • 102,507
  • 33
  • 189
  • 228
1

Check Your Java Platform Manager : Tools->Java Platforms

DanialAbdi
  • 183
  • 1
  • 4
  • 17
0

Quite some time since question was asked, but I guess that what your looking for: http://wiki.netbeans.org/FaqCompileOnSave

Lars
  • 1,013
  • 8
  • 19
0

at Program Files\NetBeans 6.8\etc there is a netbeans_jdkhome value.

Louis Rhys
  • 34,517
  • 56
  • 153
  • 221
  • It is set to `netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_20"`, my default JDK. If this is the relevant setting, NetBeans should be using the default compiler. – deamon Jul 30 '10 at 04:29