Results 1 to 6 of 6
  1. #1
    lineker is offline Member
    Join Date
    Jul 2013
    Posts
    10
    Rep Power
    0

    Default How can I change Maven Path?

    Hi,

    When I write below command:

    which mvn

    I see below output

    /usr/bin/mvn

    But it is not the maven installed by me. I think it came with linux

    Now I want to change mvn path with following command:

    export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1

    export M2=%M2_HOME%\bin


    But it does not change. I still see

    which mvn

    I see below output

    /usr/bin/mvn

    Why?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: How can I change Maven Path?

    What is your PATH? Have you tried changing that?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    lineker is offline Member
    Join Date
    Jul 2013
    Posts
    10
    Rep Power
    0

    Default Re: How can I change Maven Path?

    Hi Kevin,

    I set path too. But at path there are 2 mvn path.
    Here what I did, I am writing real paths

    export M2_HOME=~/Dev/apache-maven-3.1.1/apache-maven/src
    export M2=%M2_HOME%\bin
    export PATH=$M2:$PATH


    And I see path as follow, now there are 2 mvn path, I colored with red.

    $ $PATH
    bash: fg: %M2_HOME%bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/kadir/Dev/android-sdk-linux/tools:/home/kadir/Dev/android-sdk-linux/platform-tools:/home/kadir/Dev/eclipse:

    I check mvn

    which mvn

    output is :

    /usr/bin/mvn

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: How can I change Maven Path?

    What happens if you hardcode the path to your maven instead of using M2_HOME?

    Why are you keeping maven in /usr/bin if you have another version you want to use?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    lineker is offline Member
    Join Date
    Jul 2013
    Posts
    10
    Rep Power
    0

    Default Re: How can I change Maven Path?

    Quote Originally Posted by KevinWorkman View Post
    What happens if you hardcode the path to your maven instead of using M2_HOME?
    I removed M2_HOME as follow:

    export M2=~/Dev/apache-maven-3.1.1/apache-maven/src/bin
    export PATH=$M2:$PATH

    and when I write

    which mvn

    output is

    /home/kadir/Dev/apache-maven-3.1.1/apache-maven/src/bin/mvn

    which means it worked. But will not M2_HOME be used later? I thought it was necessary.

    Now there is another problem, I write to command

    mvn

    output is

    Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher
    Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 23)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 68)
    Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher. Program will exit.






    Why are you keeping maven in /usr/bin if you have another version you want to use?
    It came with linux I did not delete it thinking that I may break down sth at system

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: How can I change Maven Path?

    I don't know your setup, so I don't know when your M2_HOME variable is used. But if you hardcoded it and it worked, I would say that points to a problem with how you're using the variable in the path.

    Since you're getting a compiler error, I would separate that from your maven problem. What happens when you compile with javac?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 0
    Last Post: 12-30-2013, 07:01 AM
  2. Replies: 0
    Last Post: 12-17-2012, 01:32 PM
  3. setting java.library.path through eclipse and maven
    By shivamfet in forum New To Java
    Replies: 0
    Last Post: 12-19-2011, 07:24 AM
  4. Change Literal String to File Path with speratorChar
    By Jeremiah in forum New To Java
    Replies: 2
    Last Post: 08-18-2011, 07:14 PM
  5. Why doesnt the sound play when I change the path?
    By ProGenius in forum New To Java
    Replies: 10
    Last Post: 12-22-2009, 04:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •