2

My JAVA_HOME is properly set up to /usr/local/java/jdk1.7.0_01

$echo $JAVA_HOME
/usr/local/java/jdk1.7.0_01

$sudo update-alternatives --config java

There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
* 2            /usr/local/java/jdk1.7.0_01/bin/java             1         manual mode
  3            /usr/local/java/jre1.7.0_01/bin/java             1         manual mode

I am using mvn release:prepare plugin to produce the git tag and flip project's version in the pom.xml. It works perfect if I use maven 2.2.1 When I use maven 3.0.4, I get:

[INFO] Error: JAVA_HOME is not defined correctly.
[INFO]   We cannot execute /usr/local/java/jdk1.7.0_01/bin/java/bin/java

I guess there might be a bug in maven 3, when it runs, it tries to append /bin/java twice to my JAVA_HOME.

Shengjie
  • 12,336
  • 29
  • 98
  • 139

4 Answers4

2

Try using the standard Oracle/Sun JDK, if that is an option at all. I have hit this myself before on Debian/Ubuntu. I never had the patience to figure out what was wrong with the OpenJDK, but it doesn't cope well with Maven. Or... at least... such was my observation.

carlspring
  • 31,231
  • 29
  • 115
  • 197
1

JAVA_HOME must point to jre, then set :

export JAVA_HOME=/usr/local/java/jdk1.7.0_01/jre
Nelson G.
  • 5,145
  • 4
  • 43
  • 54
0

Search JAVA_HOME in your mvn command file (use which mvn to find it). Mine does handle the JAVA_HOME if not already defined.

So perhaps you can get around it by unset JAVA_HOME

Ding-Yi Chen
  • 2,830
  • 33
  • 27
0

remove the file in old maven home and it will change to new one.

mv /usr/local/Cellar/maven/3.8.1/libexec /usr/local/Cellar/maven_bak

before that, you need to export your jdk and maven firstly. and how to do this, you can see following link.

https://stackoverflow.com/a/67715235/11679986

JINSHUAI
  • 21
  • 3