The following instructions will help you to install Oracle Java 7 JDK on Ubuntu 12.04 Server. Please follow these steps only when you install Java on a fresh server.
To remove the open JDK and to install the Oracle Java, you can refer my post here.
Step 1: First check whether the Ubuntu Linux operating system architecture is 32-bit or 64-bit. Run the following command,
root@ubuntusrv:~# uname -a
Linux ubuntusrv 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
So in my case it is 64 bit OS
Step 2: Check whether Java is installed or not.
root@ubuntusrv:~# java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
* gcj-4.5-jre-headless
* openjdk-7-jre-headless
Try: apt-get install <selected package>
The above output tells us that java is not installed.
Step 3: Then create a directory called java in /ust/local. This directory will be used to hold all java binaries
root@ubuntusrv:~# sudo mkdir -p /usr/local/java
Step 4: Now download the latest version of java from here
Note:
You can download the Java from any windows machine and then you can use WinSCP to copy the same
Step 5: Now copy the downloaded file and extract the same using the following commands
root@ubuntusrv:/usr/local/java# cd /usr/local/java/
root@ubuntusrv:/usr/local/java# sudo tar xvzf server-jdk-7u51-linux-x64.tar.gz
Now remove the downloaded archive file
root@ubuntusrv:/usr/local/java# rm server-jdk-7u51-linux-x64.tar.gz
Step 6: Now add the java variables to /etc/environment file as follows
JAVA_HOME=/usr/local/java/jdk1.7.0_51
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/java/jdk1.7.0_51/bin"
Note:
:/usr/local/java/jdk1.7.0_51/bin has to be appended to the existing line
jdk1.7.0_51 is the directory extracted using tar command in the previous step
Step 7: Now restart the server and check the Java installation with the following command
root@ubuntusrv:~# java -version
You will get a response like this
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Step 8: Run the below commands to update the java installation
Step 8: Run the below commands to update the java installation
sudo update-alternatives --set java /usr/local/java/jdk1.7.0_51/bin/java
No comments:
Post a Comment