Reputation: 29
I checked the java it is installed on my system.If i enter whereis java
it shows me the
/usr/bin/java
I want to set the JAVA_HOME
, i already gave the path /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home
but it won't work.
If i enter $JAVA_HOME
it returns nothing.
If i enter this command /usr/libexec/java_home -v 1.7
it shows me the result
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home
but while setting up my local workspace it won't work it simply says
`/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home` is not valid `JAVA_HOME`
How can I resolve this issue?
Upvotes: 3
Views: 2399
Reputation: 315
Environment variables such as this are stored in bash and users use configuration files to set parameters for their bash environments.
for example in your home directory you will likely have one or both of a .bashrc or a .bash_profile file.
1) open this file
vi ~/.bash_profile
2) add the following line to this file
#Default to java 1.6
export JAVA_HOME=`/usr/libexec/java_home -v 1.6`
This will set the $JAVA_HOME variable to the path defined above. In my case:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Once you change a bash configuration file you either need to restart your terminal or source that file
source ~/.bash_profile
Then finally confirm that this worked by running the command
echo $JAVA_HOME
Upvotes: 3