This post will be useful to install oracle java 7 on ubuntu .
If you have the OpenJDK/JRE installed on your system, you can remove it by typing the following at the command line:
Type/Copy/Paste: sudo apt-get purge openjdk-\*
This command will completely remove OpenJDK/JRE from your system .
Create java folder in usr/lib/jvm , you can create it by following command line :
Type/Copy/Paste: sudo mkdir -p /usr/lib/jvm/java
This command will create a directory to hold your Oracle Java JDK and JRE binaries.
Download jdk and jre from here
Extract that files and copy and paste it into usr/lib/jvm/java folder
Edit the system PATH file /etc/profile and add the following system variables to your system path
Type/Copy/Paste: sudo gedit /etc/profile
Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file:
Type/Copy/Paste:
JAVA_HOME=/usr/lib/jre/java/jdk1.7.0_21
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/lib/jre/java/jre1.7.0_21
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Save the /etc/profile file and exit.
Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use.
Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jre/java/jre1.7.0_21/bin/java" 1
this command notifies the system that Oracle Java JRE is available for use .
Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jre/java/jdk1.7.0_21/bin/javac" 1
this command notifies the system that Oracle Java JDK is available for use
Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jre/java/jre1.7.0_21/bin/javaws" 1
this command notifies the system that Oracle Java Web start is available for use
Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java.
Type/Copy/Paste: sudo update-alternatives --set java /usr/lib/jre/java/jre1.7.0_21/bin/java
this command will set the java runtime environment for the system
Type/Copy/Paste: sudo update-alternatives --set javac /usr/lib/jre/java/jdk1.7.0_21/bin/javac
this command will set the javac compiler for the system
Type/Copy/Paste: sudo update-alternatives --set javaws /usr/lib/jre/java/jre1.7.0_21/bin/javaws
this command will set Java Web start for the system
Reload your system wide PATH /etc/profile by typing the following command:
Type/Copy/Paste: . /etc/profile
Note your system-wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system
Test to see if Oracle Java was installed correctly on your system. Run the following commands and note the version of Java:
Type/Copy/Paste: java -version
this should display
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b21)
Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)
Type/Copy/Paste: javac -version
javac 1.7.0_21
That's all you just installed Oracle Java on your Linux system .
Note : Check your JAVA_PATH and JRE_PATH in terminal by following commands :
Type/Copy/Paste: echo $JAVA_HOME
it will display /usr/lib/jvm/java/jdk1.7.0_21
Type/Copy/Paste: echo $JRE_HOME
it will display /usr/lib/jvm/java/jre1.7.0_21
If terminal show this paths then all is set . Sometimes you may not get this paths correctly that time you should follow this steps
Goto your home folder and press CTRL + F , you can get .bashrc file in that file you can export your java path add following line at end of the file or modify JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java/jdk1.7.0_21
That's all everything done ....
If you have the OpenJDK/JRE installed on your system, you can remove it by typing the following at the command line:
Type/Copy/Paste: sudo apt-get purge openjdk-\*
This command will completely remove OpenJDK/JRE from your system .
Create java folder in usr/lib/jvm , you can create it by following command line :
Type/Copy/Paste: sudo mkdir -p /usr/lib/jvm/java
This command will create a directory to hold your Oracle Java JDK and JRE binaries.
Download jdk and jre from here
Extract that files and copy and paste it into usr/lib/jvm/java folder
Edit the system PATH file /etc/profile and add the following system variables to your system path
Type/Copy/Paste: sudo gedit /etc/profile
Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file:
Type/Copy/Paste:
JAVA_HOME=/usr/lib/jre/java/jdk1.7.0_21
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/lib/jre/java/jre1.7.0_21
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Save the /etc/profile file and exit.
Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use.
Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jre/java/jre1.7.0_21/bin/java" 1
this command notifies the system that Oracle Java JRE is available for use .
Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jre/java/jdk1.7.0_21/bin/javac" 1
this command notifies the system that Oracle Java JDK is available for use
Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jre/java/jre1.7.0_21/bin/javaws" 1
this command notifies the system that Oracle Java Web start is available for use
Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java.
Type/Copy/Paste: sudo update-alternatives --set java /usr/lib/jre/java/jre1.7.0_21/bin/java
this command will set the java runtime environment for the system
Type/Copy/Paste: sudo update-alternatives --set javac /usr/lib/jre/java/jdk1.7.0_21/bin/javac
this command will set the javac compiler for the system
Type/Copy/Paste: sudo update-alternatives --set javaws /usr/lib/jre/java/jre1.7.0_21/bin/javaws
this command will set Java Web start for the system
Reload your system wide PATH /etc/profile by typing the following command:
Type/Copy/Paste: . /etc/profile
Note your system-wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system
Test to see if Oracle Java was installed correctly on your system. Run the following commands and note the version of Java:
Type/Copy/Paste: java -version
this should display
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b21)
Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)
Type/Copy/Paste: javac -version
javac 1.7.0_21
That's all you just installed Oracle Java on your Linux system .
Note : Check your JAVA_PATH and JRE_PATH in terminal by following commands :
Type/Copy/Paste: echo $JAVA_HOME
it will display /usr/lib/jvm/java/jdk1.7.0_21
Type/Copy/Paste: echo $JRE_HOME
it will display /usr/lib/jvm/java/jre1.7.0_21
If terminal show this paths then all is set . Sometimes you may not get this paths correctly that time you should follow this steps
Goto your home folder and press CTRL + F , you can get .bashrc file in that file you can export your java path add following line at end of the file or modify JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java/jdk1.7.0_21
That's all everything done ....
We has been offering customized web development company, web design, software development, mobile application and web application services to businesses of all sorts.For more information please Web Development Company and Web Development in India.
ReplyDelete