Cannot Create Maven Web Project in Netbeans 8.2

4.4k Views Asked by At

I installed netbeans 8.2 recently and I keep trying to create a maven web project but I'm getting this error.

Cannot run program "cmd" (in directory "C:\Users\Administrator\Documents\NetBeansProjects"): 
Malformed argument has embedded quote: "C:\opt\apache-maven-3.6.2\bin\mvn.cmd" 
-DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee7 
-DarchetypeVersion=1.1 -DarchetypeRepository=http://repo.maven.apache.org/maven2 
-DgroupId=com.dilini -DartifactId=mavenproject1 -Dversion=1.0-SNAPSHOT -Dpackage=com.dilini.mavenproject1 
-Dbasedir=C:\Users\Administrator\Documents\NetBeansProjects -Darchetype.interactive=false 
-Dmaven.ext.class.path="C:\Program Files\NetBeans 8.2\java\maven-nblib\netbeans-eventspy.jar" 
--batch-mode archetype:generate

I updated java ee plugings in netbeans, I added settings.xml to C:\Users\Administrator\.m2 location which I copied from the maven package.

But nothing seems to be working.
Please help

2

There are 2 best solutions below

1
On BEST ANSWER

Update March 2020 - this should be fixed in NetBeans 11.2 and later, released on 25th October 2019. Details in the bug report.

This is caused by a recent change in the JDK. Please see this question for more information. Although the question relates to JDK11 the same change was made to JDK8 and the same solution (it is a work-around, really) applies.

Edit your netbeans.conf (you will find this in your netbeans directory under etc) to add -J-Djdk.lang.Process.allowAmbiguousCommands=true to the netbeans_default_options key. You can edit with notepad but you might need to do it as an Administrator depending on how you installed NB.

For example, mine looks like:

# JDK 11 made GTK 3 default on Linux. Unfortunately it makes
# NetBeans ugly on Linux with the default GTK+ Look and Feel,
# as a workaround -J-Djdk.gtk.version=2.2 has been added to the 
# default command line arguments.
# (see: https://issues.apache.org/jira/browse/NETBEANS-1344)
#
netbeans_default_options="-J-Djdk.lang.Process.allowAmbiguousCommands=true -J-XX:+UseStringDeduplication -J-Xss2m -J-Djdk.gtk.version=2.2 -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dplugin.manager.check.updates=false -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED -J--add-modules=jdk.jshell -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"

Thanks to @Sephiroth for providing the answer.

2
On

Finally found the answer I downgraded my java version from jdk1.8.0_231 to jdk1.8.0_221.

Now everything is working fine. Hope this will help someone.