0

I was using Apache Maven 3.3.3, I put the code into the /opt directory. Then I run this command to make it works:

export PATH=/opt/apache-maven-3.3.3/bin:$PATH;

Then I run this one because JAVA_HOME wasn't defined correctly (was /usr/libexec/java_home, supposed to be /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home):

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

Now Maven work as expected.

Here comes the problem, it only works on that terminal window, when I use another window I have to run the two commands above again to make it work again, this is very annoying, is there a way to prevent this?

Thanks.

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
Tom Shen
  • 1,838
  • 3
  • 19
  • 40
  • Possible duplicate of [How set multiple env variables for a bash command](http://stackoverflow.com/questions/26189662/how-set-multiple-env-variables-for-a-bash-command) –  Nov 27 '15 at 15:55

1 Answers1

1

This is not a Maven issue, but rather an environment configuration issue.

If you are using Linux and bash, you can set this start-up configuration in your .bash_profile file located in your user home directory. If the file doesn't exist, create one with that name and put your configuration in it (the export PATH and JAVA_HOME set of your question).

You would need to close the terminal where you configured it and open a new one to get the settings available or invoke the source command (source ~/.bash_profile).

You can also run a quick test afterward with an echo command (i.e. echo JAVA_HOME) and check its content.

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
  • Is it the same if I am using Mac OS X? – Tom Shen Nov 28 '15 at 01:56
  • I don't have a Mac OS machine, put apparently yes, it's exactly the same, you can check full explanation [here](http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac) – A_Di-Matteo Nov 28 '15 at 20:39
  • You explicitly say it's not a Maven issue then added Maven tags: these are mutually-exclusive viewpoints. – Dave Newton Jun 24 '17 at 10:37
  • @DaveNewton it might seem so indeed, but you can still encounter the question thinking of having a maven issue (as it was the case) and as such finding a way to solve it. Not sure in this case whether the tag should be there or not though. – A_Di-Matteo Jun 24 '17 at 10:54