Issue
I installed Netbeans 11.3 under Ubuntu 18.04 and created in the following a new Groovy project.
- Choose File > New Project (Ctrl-Shift-N;\u2318-Shift-N on Mac) from the main menu to open the New Project wizard.
- Select Java Application in the Java category. Click Next.
Type GroovyJavaDemo as the Project Name and specify the folder where you want to create the application in the Project Location field.
Deselect the Create Main Class checkbox. Click Finish.
Next, I created a Groovy Script file with only this content println "Hello" and it caused the following problems:
ant -f /home/ubuntu/NetBeansProjects/GroovyJavaDemo -Djavac.includes=Hello.groovy -Drun.class=Hello run-single init: deps-jar: Created dir: /home/ubuntu/NetBeansProjects/GroovyJavaDemo/build Updating property file: /home/ubuntu/NetBeansProjects/GroovyJavaDemo/build/built-jar.properties Created dir: /home/ubuntu/NetBeansProjects/GroovyJavaDemo/build/classes Created dir: /home/ubuntu/NetBeansProjects/GroovyJavaDemo/build/empty Compiling 1 source file to /home/ubuntu/NetBeansProjects/GroovyJavaDemo/build/classes /home/ubuntu/NetBeansProjects/GroovyJavaDemo/nbproject/build-impl.xml:1120: The following error occurred while executing this line: /home/ubuntu/NetBeansProjects/GroovyJavaDemo/nbproject/groovy-build.xml:26: Error running forked groovyc. BUILD FAILED (total time: 1 second)
What did I miss?
Thank you in advance,
Solution
I don't think you missed anything, since I can reproduce your problem with JDK 11 on NetBeans 11.3.
However, there is a (somewhat unsatisfactory) workaround that worked for me:
- Install JDK 8 (if necessary).
- Edit the NetBeans file etc/netbeans.conf and set the JDK that NetBeans uses to JDK 8. In my case I added the line
netbeans_jdkhome="C:\Java\jdk1.8.0_221"
to netbeans.conf. Restart NetBeans then rebuild your project. It should compile now:
Notes:
- You could bug report this issue to the NetBeans team if you wish.
- I also tried using JDK 14 as the default Java platform for NetBeans and got a different error:
NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
. See the Gradle bug JDK 14 support #10248 for more information on that. - Setting JDK 8 as the default platform for NetBeans doesn't prevent you from adding other Java platforms (Tools > Java Platforms > Add Platform...) such as JDK 11 and JDK 14 for your individual projects.
Answered By - skomisa
Answer Checked By - Cary Denson (JavaFixing Admin)