It can be installed with apt-get.
$ sudo apt-get install openjdk-7-jdk
Confirmation of JDK
$ java -version java version "1.7.0_75" OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~trusty1) OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
Here, when the version is displayed for "1.6.0_xx", change it to use JDK 7. This switching is done with the update-alternatives command.
$ sudo update-alternatives --config java alternative java (provides /usr/bin/java) has 2 choices. Option path priority status ------------------------------------------------------------------------------------- * 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode Press Enter to keep the current selection [*], otherwise press the key of the choice: 2
Add the repository and install oracleJDK7.
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-jdk7-installer
Confirmation of JDK
$ java -version java version "1.7.0_76" Java(TM) SE Runtime Environment (build 1.7.0_76-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
If you also have OpenJDK installed, you can check the selection status below.
$ update-alternatives --config java alternative java (provides /usr/bin/java) has 2 choices. Option path priority status ------------------------------------------------------------------------------------- * 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1072 auto mode 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1072 manual mode Press Enter to keep the current selection [*], otherwise press the key of the choice:
For the procedure, refer to Ubuntu 14.04 above. It can be set by the same procedure.
Follow the instructions on the right to install. https://wiki.debian.org/JavaPackage
Add the following sentence to the end of /etc/apt/sources.list.
deb http://http.debian.net/debian/ wheezy main contrib
Install the required java-package to install the JDK.
# apt-get update # apt-get install java-package
Download the JDK (here jdk-7u75-linux-x64.tar.gz) from the oracle site.
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Generate and install the deb package.
$ make-jpkg jdk-7u75-linux-x64.tar.gz $ ls oracle-j2sdk1.7_1.7.0+update75_amd64.deb # dpkg -i oracle-j2sdk1.7_1.7.0+update75_amd64.deb
Select oracleJDK.
# update-alternatives --config java alternative java (provides /usr/bin/java) has 3 choices. Alternative java (provides /usr/bin/java) has 3 choices. Option path priority status ------------------------------------------------------------------------------------- 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/j2sdk1.7-oracle/jre/bin/java 317 manual mode 2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode * 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode Press Enter to keep the current selection [*], otherwise press the number of the choice: 1
Confirmation of JDK
$ java -version java version "1.7.0_75" Java(TM) SE Runtime Environment (build 1.7.0_75-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
Add the wheezy repository to the end of /etc/apt/sources.list.
# vi /etc/apt/sources.list deb http://ftp.jp.debian.org/debian/ wheezy main
Since it was added only for the installation of openjdk 7, the priority is the sqeeze version, so create a local file in / etc / apt / apt.conf.d and write the following.
# vi /etc/apt/apt.conf.d/local APT::Default-Release "squeeze";
On the other hand, the priority of the package included in wheezy is kept to a minimum. In the squeeze environment, we want to avoid having to upgrade major libraries unnecessarily.
Create a wheezy file in /etc/apt/preferences.d and write the following.
# vi /etc/apt/preferences.d/wheezy Package: * Pin: release n=wheezy Pin-Priority: 10
For priority, 100 is allocated to the package being installed, 500 is allocated to the package not installed, so specify a value smaller than 100.
# apt-get update # apt-get install -t wheezy openjdk-7-jdk
Select OpenJDK 7.
# update-alternatives --config java alternative java (provides /usr/bin/java) has 3 choices. Option path priority status ------------------------------------------------------------------------------------- * 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/bin/gij-4.7 1047 manual mode 2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode Press Enter to keep the current selection [*], otherwise press the number of the choice: 3
Confirmation of JDK
# java -version java version "1.7.0_03" OpenJDK Runtime Environment (IcedTea7 2.1.7) (7u3-2.1.7-1) OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)
Debian 6.0 does not support java-package, so install it with update-alternatives.
Download the JDK (here jdk-7u75-linux-x64.tar.gz) from the oracle site.
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Unzip it and move the generated directory jdk1.7.0_75 to /usr/lib.
# tar xvzf jdk-7u75-linux-x64.tar.gz # mv jdk1.7.0_75 /usr/lib/jvm/jdk1.7.0-oracle
Install with the update-alternatives command. At this time, the priority is specified, but here it is 1.
# update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0-oracle/bin/java" 1 # update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0-oracle/bin/javac" 1
Select oracleJDK.
# update-alternatives --config java There are four choices in alternative java (providing /usr/bin/java). Option path priority status ------------------------------------------------------------------------------------- 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/bin/gij-4.7 1047 manual mode 2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode * 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode 4 /usr/lib/jvm/jdk1.7.0-oracle/bin/java 1 manual mode Press Enter to hold the current selection [*], otherwise press the number of the choice: 4
Confirmation of JDK
$ java -version java version "1.7.0_75" Java(TM) SE Runtime Environment (build 1.7.0_75-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
It is already installed.
$ java -version java version "1.7.0_75" OpenJDK Runtime Environment (fedora-2.5.4.2.fc20-x86_64 u75-b13) OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
Download the JDK (jdk-7u75-linux-x64.rpm in this case) from the oracle site.
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Installation
# rpm -ivh jdk-7u75-linux-x64.rpm
Confirm installation destination
# ls -l /usr/java/ lrwxrwxrwx. 1 root root 16 3月 17 10:47 default -> /usr/java/latest drwxr-xr-x. 8 root root 4096 3月 17 10:46 jdk1.7.0_75 lrwxrwxrwx. 1 root root 21 3月 17 10:47 latest -> /usr/java/jdk1.7.0_75
Register oracleJDK to alternatives. At this time, if you use the /usr/java/latest path from the installation above, you can see that it does not depend on the JDK version number.
Before registering, check the Java settings.
# update-alternatives --display java java - The status is manual. The link now points to /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/java. /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/java - Priority item 170075 Slave keytool: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/keytool Slave orbd: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/orbd Slave pack200: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/pack200 Slave rmid: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/rmid Slave rmiregistry: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/rmiregistry Slave servertool: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/servertool Slave tnameserv: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/tnameserv Slave unpack200: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/unpack200 Slave jre_exports: /usr/lib/jvm-exports/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64 Slave jre: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre Slave java.1.gz: /usr/share/man/man1/java-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave keytool.1.gz: /usr/share/man/man1/keytool-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave orbd.1.gz: /usr/share/man/man1/orbd-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave pack200.1.gz: /usr/share/man/man1/pack200-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave rmid.1.gz: /usr/share/man/man1/rmid-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave rmiregistry.1.gz: /usr/share/man/man1/rmiregistry-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave servertool.1.gz: /usr/share/man/man1/servertool-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave tnameserv.1.gz: /usr/share/man/man1/tnameserv-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz Slave unpack200.1.gz: /usr/share/man/man1/unpack200-java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64.1.gz
The above result shows that orbd is registered as a slave. When invoking the name server, the path must be passed to orbd. The slave specifies what you want to switch with java installed with update-alternatives - install. Therefore, when registering oracleJDK to alternatives, we also specify with --slave option.
Also, the priority item 170075 is priority. update-alternatives --install Specify the priority when running. Since the version of OpenJDK 7 and orcleJDK 7 is the same this time, we will specify 170075 as the priority when registering oracleJDK 7.
For these reasons, register with the following settings.
# update-alternatives --install /usr/bin/java java /usr/java/latest/bin/java 170075 --slave /usr/bin/javac javac /usr/java/latest/bin/javac --slave /usr/bin/javaws javaws /usr/java/latest/bin/javaws --slave /usr/bin/keytool keytool /usr/java/latest/bin/keytool --slave /usr/bin/orbd orbd /usr/java/latest/bin/orbd --slave /usr/bin/pack200 pack200 /usr/java/latest/bin/pack200 --slave /usr/bin/rmid rmid /usr/java/latest/bin/rmid --slave /usr/bin/rmiregistry rmiregistry /usr/java/latest/bin/rmiregistry --slave /usr/bin/servertool servertool /usr/java/latest/bin/servertool --slave /usr/bin/tnameserv tnameserv /usr/java/latest/bin/tnameserv --slave /usr/bin/unpack200 unpack200 /usr/java/latest/bin/unpack200
Select oracleJDK.
# update-alternatives --config java There are 2 programs and provide 'java'. Selection command ----------------------------------------------- *+ 1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.fc20.x86_64/jre/bin/java 2 /usr/java/latest/bin/java Press Enter to hold the current selection [+] or enter the selection number: 2
Confirmation of JDK
# java -version java version "1.7.0_75" Java(TM) SE Runtime Environment (build 1.7.0_75-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)