Maven not finding java

Asked

Viewed 186 times

1

I’m trying to run the Maven and is returning me the following error:

/opt/apache-maven-3.3.3/bin/mvn: 227: exec: /opt/jdk1.7.0_79/bin/java: not found

I checked the paths and are ok, someone knows why the problem?

Man Environment is like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:‌​/usr/games:/usr/local/games:/opt/java/bin:/opt/maven/bin"
JAVA_HOME="/opt/java"
M2_HOME="/opt/maven"
JAVA_OPTS="-Xms1024m -Xmx1536m -XX:MaxPermSize=200m"
MAVEN_OPTS="-XX:MaxPermSize=300m -Xms500m -Xmx1300m -Dfile.encoding=ISO-8859-1 -Dencoding=ISO-8859-1"
  • Tries to run a /opt/apache-maven-3.3.3/bin/mvn -version and a /opt/jdk1.7.0_79/bin/java -version, and put there what he writes as an answer.

  • Thanks for the answer, when I run Maven, I get the same error, since when I run java -version... it appears "-bash: /opt/jdk1.7.0_79/bin/java: File or directory not found" strange because I can manually go there and run java -version.

  • Have you set up the Maven in your path? http://stackoverflow.com/questions/6462247/how-to-setup-path-for-maven, do you have anything like that? M2_HOME=C: Program Files Apache Software Foundation apache-Maven-2.2.1 M2=%M2_HOME% bin MAVEN_OPTS=-Xms256m -Xmx512m

  • Yes, look at my file enviroment... PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/java/bin:/opt/Maven/bin" JAVA_HOME="/opt/java" M2_HOME="/opt/Maven" JAVA_OPTS="-Xms1024m -Xmx1536m -XX:Maxpermsize=200m" MAVEN_OPTS="-XX:Maxpermsize=300m -Xms500m -Xmx1300m -Dfile.encoding=ISO-8859-1 -Dencoding=ISO-8859-1"

1 answer

3


Your JAVA_HOME and your M2_HOME are wrong. Yours are like this:

JAVA_HOME="/opt/java"
M2_HOME="/opt/maven"

They should be like this:

JAVA_HOME="/opt/jdk1.7.0_79"
M2_HOME="/opt/apache-maven-3.3.3"

Your PATH is also wrong. Yours is like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:‌​/usr/games:/usr/local/games:/opt/java/bin:/opt/maven/bin"

It should be like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:‌​/usr/games:/usr/local/games:/opt/jdk1.7.0_79/bin:/opt/apache-maven-3.3.3/bin"
  • Thanks for answering, it was like this before, I just changed to make it easier to handle.

  • Very good @Victorstafusa, haha was quicker in response

Browser other questions tagged

You are not signed in. Login or sign up in order to post.