Hi all again I coming with the Ubuntu hint. This about java.I got installed java 7 using the ubuntu software center, after successful completion of my installation I unable to execute my javac command.
and I decided to go with the terminal to install the java 6
apt-get install <java package>
it installed and stored on the location of
/usr/lib/jvm/default
/java-1.6.0-openjdk
/java-7-openjdk-i386
after looking all the installed folder under my JVM folder, I had a confusion, I would decided to check which java version is taking by default. It was abusively the java 6, which Installed as recently.
But every one may look to use the latest version of java as i liked.
so i tried to find echo $JAVA_HOME, but the result empty echo message on terminal. then how the javac executing with out setting any JAVA_HOME/Path. Its terminal will look all command from the location of /usr/bin, there is javac is available by default.
so when you want to change the java version , you have to set the JAVA_HOME using following,
Set JAVA_HOME / PATH for a single user
Login to your account and open .bash_profile file
$ gedit ~/.bash_profile
Set JAVA_HOME as follows using syntax export
JAVA_HOME=<path-to-java>.
If your path is set to
/usr/lib/jvm/java-1.6.0-openjdk, set it as follows:
export JAVA_HOME=/usr/jvm/java-1.6.0-openjdk
Set PATH as follows:
export PATH=$PATH:/usr/lib/jvm/java-1.6.0-openjdk/bin
Feel free to replace /usr/lib/jvm/java-1.6.0-openjdk as per your setup. Save and close the file. Just logout and login back to see new changes. Alternatively, type the following command to activate the new path settings immediately:
$ source ~/.bash_profile
OR
$ . ~/.bash_profile
Verify new settings:
$ echo $JAVA_HOME
$ echo $PATH
Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
$ which java
Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.
Set JAVA_HOME / PATH for all user
You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
# gedit /etc/profile
Next setup PATH / JAVA_PATH variables as follows:
export PATH=$PATH:/usr/lib/jvm/java-1.6.0-openjdk/bin
export PATH=$PATH:/usr/lib/jvm/java-1.6.0-openjdk/bin
Save and close the file. Once again you need to type the following command to activate the path settings immediately:
# source /etc/profile
OR
# . /etc/profile
No comments:
Post a Comment