Some times you might already fixed environment variables but after session out.. it will disappear.. in that case you have to do like this.
Here I explained how to setup environment variable for Maven, Java
Since your installation works on the terminal you installed, all the exports you did, work on the current bash and its child process. but is not spawned to new terminals.
env variables are lost if the session is closed; using .bash_profile, you can make it available in all sessions, since when a bash session starts, it 'runs' its .bashrc and .bash_profile
Now follow these steps and see if it helps:
Now you have the PATH for M2_HOME and JAVA_HOME.
If you just do ls /usr/local/apache-maven/apache-maven-3.1.1/bin, you will see mvn binary there.
All you have to do now is to point to this location everytime using PATH. Since bash searches in all the directory path mentioned in PATH, it will find mvn.
Add the following:
#set JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
export JAVA_HOME
M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1
export M2_HOME
PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH
After this click on esc button and : and wq so that your file will save.
Now type
source ~/.bash_profile click enter
This steps executes the commands in the .bash_profile file and you are good to go now.
Now type mvn --version
|
No comments:
Post a Comment