Tuesday, September 5, 2017
Setting up JAVA HOME on Ubuntu
Setting up JAVA HOME on Ubuntu
In the following post, we will follow steps to set up JAVA_HOME for our environment.
First, become root
$ sudo su
and enter password

Next check java install folder
$ which java

However this is just the symbolic link. To find the actual folder, we will use the following command.
$ readlink -f $(which java)

Now we will create a new symbolic link for the actual folder within /usr/lib/jvm called default-java pointing to my Oracle JDK in this case. This will allow me to re-point the symbolic link to any future versions if needed.
$ cd /usr/lib/jvm
$ sudo ln -s /usr/lib/jvm/jdk1.8.0-oracle default-java

Next, go back to home and open the .bashrc file in editor
$ cd
$ gedit .bashrc

Add the following lines at the end of the file
JAVA_HOME=/usr/lib/jvm/default-java
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

Now save and close this file, and close the terminal
Open a new terminal using Ctrl-Alt-T
Enter the command
$ echo $JAVA_HOME
$ java -version
You should see the JAVA_HOME as well as version of Java installed. This way of setting up can allow you to update the current JVM using update-alternatives command. So see how to configure using update alternatives, refer to my previous post.

Thats it!
download file now
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.