Uncompilable source code - Erroneous sym type:

This is a common issue which I get while working. What I do is clean and build the project. It solves the problem.

Right Click on the project name >> Clean and build


The code you provided runs fine on my computer.

I'm guessing you are using Netbeans and may be affected by a bug. Try this:

Open the project properties, select the Build-Compiling, uncheck "Compile on save" and rerun the application. This will make sure all your source code becomes recompiled before running it.

Link: https://forums.netbeans.org/topic43241.html


Download/install JDK major version number the same as NetBeans.

i.e. If You have NetBeans 9 version, but your JDK is version 10,then try use NetBeans 10 version... or download/install JDK 9 (the same as NetBeans).

Create new java platform for new jdk installation.

Open netbeans menubar->tools->Java Platforms->Add Platform Specify the folder that contains the Java platform as well as the sources and Javadoc needed for debugging.

Set new java platform to your project

Right click on project ->properties->Libraries->Java Platform->select the jdk version that same as NetBeans

Select source format of your project

Right click on project ->properties->Sources->Sources/binary format->select the jdk version that same as NetBeans.

If it still gives errors like,

Exception in thread "main" java.lang.RuntimeException: 
at javaapplication2.JavaApplication2.main(JavaApplication2.java:1)
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 1 second)

do as "sinclair" has mentioned above. Open the project properties, select the Build-Compiling, uncheck "Compile on save" and rerun the application. This will make sure all your source code becomes recompiled before running it.

Tags:

Java