The following describes how to install the JavaRuntime and SDK of Oracle in the Ubuntu operating system. After Ubuntu is installed by default, an open-source JavaSE and OpenJDK (Open Java Development Kit) are built in the system. However, both are incompatible with OracleJava. Therefore, in some cases, we also need to install OracleJava and delete OpenJDK. Below I
The following describes how to install the Java Runtime and SDK of Oracle in the Ubuntu operating system.
After Ubuntu is installed by default, an open source Java SE and OpenJDK (Open Java Development Kit) will be built in the system. However, both are incompatible with Oracle Java.
Therefore, in some cases, we also need to install Oracle Java and delete OpenJDK. The following describes the process.
We can start with a fully-installed Ubuntu 12.10, both 32-bit and 64-bit. We need to get the JRE and JDK of Oracle and pay for it at the end. Now, run the command directly. You only need to input the following command line to your terminal. If there is no accident, this process will be completed correctly. Of course, when you need a password, enter your password.
First, three public commands, whether you are a 32-bit system or a 64-bit system, are the same:
Sudo apt-get purge openjdk -\*
Sudo mkdir-p/usr/local/java
Cd/home/"your_user_name"/Downloads
If you are a 32-bit system, enter the following command:
Sudo-s cp-r jdk-7u9-linux-i586.tar.gz/usr/local/java
Sudo-s cp-r jre-7u9-linux-i586.tar.gz/usr/local/java
Cd/usr/local/java
Sudo-s chmod a + x jdk-7u9-linux-i586.tar.gz
Sudo-s chmod a + x jre-7u9-linux-i586.tar.gz
Sudo-s tar xvzf jdk-7u9-linux-i586.tar.gz
Sudo-s tar xvzf jre-7u9-linux-i586.tar.gz
If you are a 64-bit system, enter the following command:
Sudo-s cp-r jdk-7u9-linux-x64.tar.gz/usr/local/java
Sudo-s cp-r jre-7u9-linux-x64.tar.gz/usr/local/java
Cd/usr/local/java
Sudo-s chmod a + x jdk-7u9-linux-x64.tar.gz
Sudo-s chmod a + x jre-7u9-linux-x64.tar.gz
Sudo-s tar xvzf jdk-7u9-linux-x64.tar.gz
Sudo-s tar xvzf jre-7u9-linux-x64.tar.gz
Now, for 32-bit Ubuntu or 64-bit Ubuntu, run the following command to edit the profile file:
Sudo gedit/etc/profile
Paste the following code into the Editor:
JAVA_HOME =/usr/local/java/jdk1.7.0 _ 09
PATH = $ PATH: $ HOME/bin: $ JAVA_HOME/bin
JRE_HOME =/usr/local/java/jre1.7.0 _ 09
PATH = $ PATH: $ HOME/bin: $ JRE_HOME/bin
Export JAVA_HOME
Export JRE_HOME
Export PATH
Save and close gedit, and then enter the following command:
Sudo update-alternatives -- install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0 _ 09/bin/java" 1
Sudo update-alternatives -- install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0 _ 09/bin/javac" 1
Sudo update-alternatives -- install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0 _ 09/bin/javaws" 1
Sudo update-alternatives -- set java/usr/local/java/jre1.7.0 _ 09/bin/java
Sudo update-alternatives -- set javac/usr/local/java/jdk1.7.0 _ 09/bin/javac
Sudo update-alternatives -- set javaws/usr/local/java/jre1.7.0 _ 09/bin/javaws
./Etc/profile
OK. Now that Oracle Java has been installed, start various tests now.
JRE (Java 2 Standard Edition Runtime Environment 7 Update 9) and JDK (Java SE Development Kit 7 Update 9 ):
- Http://jdk7.java.net/download.html