How to install java and set environment variables in linux
What is JAVA?
Java is a programming language designed for use in the distributed environment of the Internet. Java can be used to create complete applications that may run on a single computer or be distributed among servers and clients in a network. It can also be used to build a small application module or applet for use as part of a Web page. Applets make it possible for a Web page user to interact with the page.
Both jdk x64 and x86 installation are same
Step1: Go to oracle website and download Linux jdk (eg: jdk-7u79-linux-i586.gz)
Step2: Extract it to /opt/app/ (or any where you want to be install)
Command: tar -xvf jdk-7u79-linux-i586.gz
After you extract you will see: "jdk1.7.0_79"
/opt/app/jdk1.7.0_79
Create a softlink:
Command: ln -s jdk1.7.0_79 jdk
After you create a softlink you will see: "jdk -> jdk1.7.0_79"
/opt/app/jdk -> jdk1.7.0_79
Step3: Setting environment path globally
create a file jdk.sh with below commands:
Command: vi /etc/profile.d/jdk.sh
Add the below lines and save the file:
export JAVA_HOME=/opt/app/jdk
export PATH=$JAVA_HOME/bin:$PATH
Now source the jdk.sh to use the new jdk
Command: source /etc/profile.d/jdk.sh
confirm jdk installed and environment setup properly:
Command: which java
/opt/app/jdk/bin/java
Command: java -version
java version "1.7.0_79"
Command: javac -version
javac 1.7.0_79
Note: Softlink helps to avoide making changes to jdk.sh while upgrading jdk to higher version jdk-xxx-linux-i586.gz.
Video Tutorial On How to Install java on Linux
Java is a programming language designed for use in the distributed environment of the Internet. Java can be used to create complete applications that may run on a single computer or be distributed among servers and clients in a network. It can also be used to build a small application module or applet for use as part of a Web page. Applets make it possible for a Web page user to interact with the page.
Both jdk x64 and x86 installation are same
Step1: Go to oracle website and download Linux jdk (eg: jdk-7u79-linux-i586.gz)
Step2: Extract it to /opt/app/ (or any where you want to be install)
Command: tar -xvf jdk-7u79-linux-i586.gz
After you extract you will see: "jdk1.7.0_79"
/opt/app/jdk1.7.0_79
Create a softlink:
Command: ln -s jdk1.7.0_79 jdk
After you create a softlink you will see: "jdk -> jdk1.7.0_79"
/opt/app/jdk -> jdk1.7.0_79
Step3: Setting environment path globally
create a file jdk.sh with below commands:
Command: vi /etc/profile.d/jdk.sh
Add the below lines and save the file:
export JAVA_HOME=/opt/app/jdk
export PATH=$JAVA_HOME/bin:$PATH
Now source the jdk.sh to use the new jdk
Command: source /etc/profile.d/jdk.sh
confirm jdk installed and environment setup properly:
Command: which java
/opt/app/jdk/bin/java
Command: java -version
java version "1.7.0_79"
Command: javac -version
javac 1.7.0_79
Note: Softlink helps to avoide making changes to jdk.sh while upgrading jdk to higher version jdk-xxx-linux-i586.gz.
Video Tutorial On How to Install java on Linux
Comments
Post a Comment
Please comment