JDK1.6のインストールとAlternatives

毎回インストール方法が簡単になるけど、反面ブラックボックス化して理解不能になるので覚え書き。

ここから、jdk-6u30-linux-x64.bin をダウンロードして解凍。
ちなみに、jdk-6u30-linux-x64-rpm.bin は勝手にインストールしてくれるので、自分的にはNG。

余談だが、X86 と X64 は、64bit版がX64で、32bit版がX86。
数値の大小がまぎらわしい。 Windows7 と Windows98 みたいなもの・・・。

[bash]
[user@server src]$ sudo ./jdk-6u30-linux-x64.bin
Unpacking…
Checksumming…
Extracting…
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
creating: jdk1.6.0_30/
creating: jdk1.6.0_30/db/
creating: jdk1.6.0_30/db/bin/
inflating: jdk1.6.0_30/db/bin/ij

…省略

Creating jdk1.6.0_30/jre/lib/ext/localedata.jar
Creating jdk1.6.0_30/jre/lib/plugin.jar
Creating jdk1.6.0_30/jre/lib/javaws.jar
Creating jdk1.6.0_30/jre/lib/deploy.jar

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.
[/bash]

解凍されたディレクトリを、お好みの場所へ移動。
[bash]
[user@server src]$ sudo mv jdk1.6.0_30 /usr/local/jdk1.6
[user@server src]$ ls /usr/local/jdk1.6/
[/bash]

javaのバージョンを調べると古いまま・・・。
どうやらalternatives というもので管理されているよう。
OS初期状態では、/usr/lib/jvm/jre-1.4.2-gcj/bin/java が実態としてリンクされている模様。
[bash]
[root@servere ~]# alternatives –config java

1 プログラムがあり ‘java’ を提供します。

選択 コマンド
———————————————–
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:
[/bash]

alternatives –install で、今回インストールしたディレクトリを指定する。
ちなみに、最後の30は優先順位らしいが、いくつでもよい。指定しないと怒られる。
[bash]
[root@server ~]# alternatives –install /usr/bin/java java /usr/local/jdk1.6/bin/java 30
[root@server ~]# alternatives –config java

2 プログラムがあり ‘java’ を提供します。

選択 コマンド
———————————————–
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
2 /usr/local/jdk1.6/bin/java

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
[/bash]

どうやら上手くいったようだ。

ちなみに、ユーザは /usr/bin/java を環境変数のパスで参照しに行っている。
/usr/bin/java → /etc/alternatives/java → /usr/local/jdk1.6/bin/java

慣れれば便利だが、知らないと手動で ln -s してしまいそう。
下記のコマンドは、alternativesを使用しているようなので気を付けよう。

[bash]
antlr ksh mta-newaliases print-cancel print-lpqman
java ksh-man mta-newaliasesman print-cancelman print-lprm
jaxp_parser_impl ksh-usrbin mta-pam print-lp print-lprman
jre_1.4.2 mta mta-rmail print-lpc print-lprmman
jre_1.4.2_exports mta-aliasesman mta-sendmail print-lpcman print-lpstat
jre_gcj mta-mailq mta-sendmailman print-lpman print-lpstatman
jre_gcj_exports mta-mailqman print print-lpq xinputrc
[/bash]

This entry was posted in CentOS, Java, 技術情報. Bookmark the permalink.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です