Question

I have a NetBeans Platform project build with Maven2. When I try to create a new platform module I get this strange error:

cd ~/src; JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java ~/netbeans-7.3/java/maven/bin/mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes...
Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/lib/jvm/jdk1.7.0/bin/java/bin/java

In ~/.bashrc I have definition of JAVA_HOME:

export JAVA_HOME="/usr/lib/jvm/jdk1.7.0"
export JDK_HOME="/usr/lib/jvm/jdk1.7.0"

There's no slash at the end, however maven appends /bin/java/bin/java to this path. I can build already existing module with Maven without problems, just when creating a new one it fails. Where does Maven get this JAVA_HOME?

EDIT: maven settings:

$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.7.0_17
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.2.0-39-generic" arch: "amd64" Family: "unix"
Was it helpful?

Solution 3

the problem was with incorrect definition of JAVA_HOME in ~/.bash_profile

NetBeans integration of maven prefers:

System.getenv("JAVA_HOME")

before:

System.getProperty("java.home")

OTHER TIPS

You're redefining JAVA_HOME on the command line to point to /usr/lib/jvm/jdk1.7.0/bin/java, which is wrong:

cd ~/src; JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java ...

Remove the JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java from the command line:

cd ~/src; ~/netbeans-7.3/java/maven/bin/mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes...

netbeans takes the JAVA_HOME from the definition of the Java Platform in the IDE (See Tools/Java Platforms)

unless you select a custom platform, IDE uses the default one which is the one the IDE is running on.

All platforms need to be defined in the Tools/Java Platforms dialog and validation checks are in place to select the right folder.

Maybe something changed in time for you and the definition there is not correct?

for linux find the mvn executalble file under netbeans's java/maven/bin folder and add

from="/bin/bin/java"
to="/bin/java"
JAVACMD="${JAVACMD/$from/$to}" 

before the lines

if [ ! -x "$JAVACMD" ] ; then
  echo "Error: JAVA_HOME is not defined correctly."

cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top