The author of this article is a general company developing its own products for Java / .NET. When it comes to Enterprise, support for Java 1.4 is still required, so we are building a development environment with Java 1.4. If you do not do this, you will not be able to develop your own products.
So, some installers for Java 1.4 of Windows have been inherited from generation to generation & even in the 32bit version, It works (looks like) on Windows, but not on the Linux version. I looked around various articles, but there was no environment where all the information was compiled, so I wrote it in the hope that it would help someone in need. (Is there such a person ...?)
TL;DR
I don't like the environment getting dirty by trial and error, so I use Docker.
Get the binaries from Oracle's Java Archive Download Site (https://www.oracle.com/java/technologies/java-archive-javase-v14-downloads.html).
$ mkdir /usr/local/java/
$ unzip j2sdk-1_4_2_19-linux-i586.bin -d /usr/local/java/
In the case of the default CentOS image, I think that the unzip command is not included, so please install it.
Set the standard JAVA_HOME
$ export JAVA_HOME=/usr/local/java/j2sdk1.4.2_19
#Also specify the PATH
$ export PATH=${PATH}:${JAVA_HOME}/bin
$ java -version
$ bash: /usr/local/java/j2sdk1.4.2_19/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
That ...?
It seems to be a glibc compatible library needed to run binaries built for 32bit. Without it, it won't work on 64-bit Linux.
$ yum install -y ld-linux.so.2
$ java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
~~ Yes Kuso ~~
It seems that the cause is that $ {JAVA_HOME $} /lib/rt.jar
is missing, or java / lang / Object.class
is missing in it.
The rt.jar is not included in the downloaded binary. .. ..
$ cd ${JAVA_HOME}/lib
$ ls -al | grep rt.jar -c
0
I read a lot of information and searched, but I couldn't find a good way.
$ mkdir /usr/local/java/
# /Put the binary in tmp
$ chmod +x /tmp/j2sdk-1_4_2_19-linux-i586.bin
$ cd /usr/local/java/
#Run binary
$ /tmp/j2sdk-1_4_2_19-linux-i586.bin
・
・
・
License lasts for a long time
・
・
Do you agree to the above license terms? [yes or no]
#When this text appears, enter yes only if you agree to the license terms and press enter to start the installation.
# JAVA_Set HOME
$ export JAVA_HOME=/usr/local/java/j2sdk1.4.2_19
#Also specify the PATH
$ export PATH=${PATH}:${JAVA_HOME}/bin
You can now run it safely.
$ java -version
java version "1.4.2_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)
Just in case, let's try build-execution.
Hello.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
Hello, World seen from the face of the parents ...
$ javac Hello.java
$ java Hello
Hello, World
I think I managed to do something
Java these days seems to be usable as long as you install the binaries and pass the PATH, so if you try to do it in a good way, it seems to have failed. .. .. Binary installation is easy and nice!
~~ If you bring the executable file (JAVA_HOME) to another environment after installing it, it will work as long as you have ld-linux.so.2. ~~
Recommended Posts