end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

install java6 to rhel8 , use via alternatimes

Step 0 - インストール先

$ cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.4 (Ootpa)
$ uname --all
Linux rhel8.a5.jp 4.18.0-305.el8.x86_64 #1 SMP
Thu Apr 29 08:54:30 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux

Step 1 - ダウンロード

download java6 from https://www.oracle.com/java/technologies/oracle-java-archive-downloads.html

Step 2 - javaをインストール

と言っても、自己解凍ファイルの jdk-6u45-linux-x64.bin を実行するだけ。

$ sudo su -
# cd /usr/local
# mkdir java
# cd java

# cp ~end0tknr/tmp/jdk-6u45-linux-x64.bin .
# ./jdk-6u45-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_45/
   creating: jdk1.6.0_45/db/
   creating: jdk1.6.0_45/db/bin/
  inflating: jdk1.6.0_45/db/bin/ij   
  inflating: jdk1.6.0_45/db/bin/NetworkServerControl  
  inflating: jdk1.6.0_45/db/bin/setNetworkClientCP.bat  
  inflating: jdk1.6.0_45/db/bin/setEmbeddedCP.bat
  <略>
   creating: jdk1.6.0_45/include/linux/
  inflating: jdk1.6.0_45/include/linux/jawt_md.h  
  inflating: jdk1.6.0_45/include/linux/jni_md.h  
  inflating: jdk1.6.0_45/include/jvmti.h  
  inflating: jdk1.6.0_45/include/jawt.h  
  inflating: jdk1.6.0_45/include/jdwpTransport.h  
  inflating: jdk1.6.0_45/include/classfile_constants.h  
  inflating: jdk1.6.0_45/COPYRIGHT   
Creating jdk1.6.0_45/jre/lib/rt.jar
Creating jdk1.6.0_45/jre/lib/jsse.jar
Creating jdk1.6.0_45/jre/lib/charsets.jar
Creating jdk1.6.0_45/lib/tools.jar
Creating jdk1.6.0_45/jre/lib/ext/localedata.jar
Creating jdk1.6.0_45/jre/lib/plugin.jar
Creating jdk1.6.0_45/jre/lib/javaws.jar
Creating jdk1.6.0_45/jre/lib/deploy.jar
 
Done.
#

Step 3 - libnsl.so.1 を追加インストール

rhel8では、libnsl.so が含まれなくなったらしく、 以下を参考に yum で、これをインストール。

RHEL 8へのインストール中に「libnsl.so.1 が必要ですが、見つかりません」メッセージが表示される

$ /usr/local/java/jdk1.6.0_45/bin/java -version
Error occurred during initialization of VM
Unable to load native library: libnsl.so.1:
  cannot open shared object file: No such file or directory


$ sudo yum install /lib64/libnsl.so.1

$ /usr/local/java/jdk1.6.0_45/bin/java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Step 4 - alternatives にjavaを登録

# alternatives --install /usr/local/java_home java_home /usr/local/java/jdk1.6.0_45 1

# alternatives --config java_home
There is 1 program that provides 'java_home'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/local/java/jdk1.6.0_45


# vi /etc/bashrc
 
export JAVA_HOME=/usr/local/java_home
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar


$ which java
/usr/local/java_home/bin/java