Meghan
Meghan

Reputation: 305

finding maven version & set MAVEN_HOME in ubuntu

I think I have jumbled up something. yesterday things were working fine. Having lots of problems today..

1.I ran this command

echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64/

then

mvn --version
Error: Could not find or load main class    org.codehaus.plexus.classworlds.launcher.Launcher

yesterday it was working fine (returning maven version, 3.0.4 , I think) . Now this has started creating problems. what to do ?

  1. Also after running

    $java --version Unrecognized option: --version Could not create the Java virtual machine.

here is the content of my .bashrc file and I have nothing in my /etc/environment file.

PATH=$PATH:$HOME/.rvm/
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

and this is in my /etc/profile

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
PATH=$PATH:$HOME:$JAVA_HOME/bin
export JAVA_HOME
export PATH
  1. Also let me know, how can i set MAVEN_HOME in it..

Any help would be appreciated. Thanks :)

Upvotes: 6

Views: 18144

Answers (3)

Meghan
Meghan

Reputation: 305

there was just one mistake that was java --version. It should be java -version (single dash) otherwise it is working fine now...

Upvotes: 1

George Sun
George Sun

Reputation: 116

http://www.johnlabarge.com/post/33156663109/dreaded-maven-error-could-not-find-or-load-main-class This link could help, just remove the M2_HOME variable, then add M3_HOME variable.

BTW, to print Java version no, you should enter java -version, rather than java --version, only single dash is needed, but with Maven, both 'mvn -version' and mvn --version are ok.

Upvotes: 0

Gerold Broser
Gerold Broser

Reputation: 14762

Maybe my config gives you a hint:

/$ uname -a
Linux jenkins 3.2.0-55-generic #85-Ubuntu SMP Wed Oct 2 12:29:27 UTC 2013 \
  x86_64 x86_64 x86_64 GNU/Linux

/$ echo $PATH
/var/lib/jenkins/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin

/$ ls -l /usr/bin/java* / usr/bin/mvn*
lrwxrwxrwx 1 root root 22 Feb 21  2013 java -> /etc/alternatives/java
lrwxrwxrwx 1 root root 23 Feb 21  2013 javac -> /etc/alternatives/javac
lrwxrwxrwx 1 root root 24 Feb 21  2013 javaws -> /etc/alternatives/javaws
lrwxrwxrwx 1 root root 21 Feb 21  2013 mvn -> /etc/alternatives/mvn
lrwxrwxrwx 1 root root 26 Feb 21  2013 mvnDebug -> /etc/alternatives/mvnDebug

/$ ls -l /etc/alternatives/java* /etc/alternatives/mvn*
lrwxrwxrwx 1 root root 17 May 31  2013 /etc/alternatives/java -> \
  /opt/jdk/bin/java
lrwxrwxrwx 1 root root 18 May 31  2013 /etc/alternatives/javac -> \
  /opt/jdk/bin/javac
lrwxrwxrwx 1 root root 58 Feb 21  2013 /etc/alternatives/javaws.1.gz -> \
  /usr/lib/jvm/java-6-openjdk-amd64/jre/man/man1/javaws.1.gz
lrwxrwxrwx 1 root root 24 Feb 21  2013 /etc/alternatives/mvn -> \
  /usr/share/maven/bin/mvn
lrwxrwxrwx 1 root root 29 Feb 21  2013 /etc/alternatives/mvn.1.gz -> \
  /usr/share/maven/man/mvn.1.gz
lrwxrwxrwx 1 root root 29 Feb 21  2013 /etc/alternatives/mvnDebug -> \
  /usr/share/maven/bin/mvnDebug
lrwxrwxrwx 1 root root 34 Feb 21  2013 /etc/alternatives/mvnDebug.1.gz -> \
  /usr/share/maven/man/mvnDebug.1.gz

/usr/share/maven/conf/m2.conf:

main is org.apache.maven.cli.MavenCli from plexus.core

set maven.home default ${user.home}/m2

[plexus.core]
optionally ${maven.home}/lib/ext/*.jar
load       ${maven.home}/lib/*.jar

/$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

/$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /opt/jdk1.7.0_21/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-55-generic", arch: "amd64", family: "unix"

Upvotes: 4

Related Questions