トップページに戻る


CentOS LogoJDK 6の導入
最終更新日:2012.02.10

公式のJDK 6(1.6.x)系をダウンロードしてCentOS 5に導入する手順をまとめておく。
なお、インストール前にJDKおよびJREがインストールされていないか確認しておくこと。

JDKのダウンロード

(1)以下からJDK 6の最新版をダウンロードする
http://www.oracle.com/technetwork/java/javase/downloads/

(2)"Accept License Agreement"を選んでライセンスに同意する
Push Accept License

(3)rpm版とバイナリ版があるので、最新版バイナリ版をダウンロードする。(2012/02/02現在の最新版はJDK 6.0 Update 30)

JDKのインストール

(4)バイナリファイルを実行する

# sh jdk-6u30-linux-x64.bin

(5)Javaの利用に関する注意事項が表示されるので、利用する場合はEnterキーを押す

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and 
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....

Done.

(6)展開されたJDKを以下にコピーする

# cp -R jdk1.6.0_30/ /usr/lib/java-1.6.0/jdk1.6.0_30/

パスの登録と反映

(7)Javaのパスを登録する

# vi /etc/profile
:
: (末尾に追記)
#Export JDK
export JAVA_HOME=/usr/lib/java-1.6.0/jdk1.6.0_30/
export JRE_HOME=/usr/lib/java-1.6.0/jdk1.6.0_30/jre/
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

ポイント

この手順ではJDKとJDK組み込みのJREをパス登録しているが、実行環境は別のJREを使う場合、JRE_HOMEとして定義している方は記述しなくても良い。

(8)パスを反映させる

# source /etc/profile

確認

JDK

# javac -version
javac 1.6.0_30
:

JRE

# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

以上で導入が完了する。