Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compiling and running java8/jdk8 code in netbeans - Uncompilable source code

After playing with preview of JDK 1.8 in notepad and compiling files from command line, I thought I would try with netbeans and see what happens.

I have successfully added JDK 1.8 and changed the following settings:

properties -> libraries -> java platform: JDK 1.8

properties -> sources -> Source/Binary format: JDK 8

When I Clean and build the project from netbeans, it builds successfully. And suggests to execute project with following command:

javac 1.8.0-ea

To run this application from the command line without Ant, try:

C:\Program Files\Java\jdk1.8.0/bin/java -jar "C:\Java8\JavaBacon\dist\JavaBacon.jar"

and it runs just fine from command line!

But when I try to Run the project, I get following exception:

Exception in thread "main" java.lang.RuntimeException: 
Uncompilable source code - Erroneous tree type: <any>

It can build, but can't run??

My current workaround for this, is just to put the Java8 code in separate Java Class Library and call it from main project, since it can build the library. Obviously when using java8 features, you get red squiggles, lack of intellisense and autoformatting changes -> to - >, but it builds! ( very nice :D )

But what is the reason for not being able to Run the project?

UPDATE:

The exception goes away when disabling Compile On Save setting under:

Properties > Build > Compiling

http://netbeans.org/bugzilla/show_bug.cgi?id=199293

like image 676
Nikita Ignatov Avatar asked Apr 08 '12 22:04

Nikita Ignatov


People also ask

How can I view source code in NetBeans?

Right click, and from the context menu select Navigate > Go to Source and you should be redirected to the appropriate position within the source of the JDK class. Alternatively, press Ctrl + Shift + B.

Which version of JDK is required for NetBeans 8.0 2?

But you need to set JDK path as JDK 8 in the system path (like you did for JDK 9). While installing Netbeans select JDK 8 installation path as JDK for Netbeans.

How do I run a single Java file in NetBeans?

You can compile and run an individual file (as opposed to a whole project) using the IDE's Compile File (F9) and Run File (Shift-F6) commands. If you use the Run Main Project command, the IDE will run the file that the IDE associates as the main class of the main project.

Which JDK is compatible with NetBeans 13?

The Apache NetBeans 13 binary releases require JDK 11+, and officially support running on JDK 11 and JDK 17.


1 Answers

The exception goes away when disabling Compile On Save setting under:

Properties > Build > Compiling

Reference: netbeans bug database

like image 70
assylias Avatar answered Oct 22 '22 18:10

assylias