无法 运行 旧的 Java 二进制 Linux 64 位

Unabled to run an old Java binary in a Linux 64bits

几个月前我已经解决了一个问题,我又(有点)陷入了困境。我需要运行一个Java虚拟POS,根据官方手册,需要JavaVM 1.4.2,但是环境是DebianGNU/Linux7"Wheezy" amd64,我还没有找到该体系结构的特定版本(Solaris amd64 或 IA64 也不适合我的情况)。该虚拟 POS 一直运行良好,但在 Debian GNU/Linux 6 "Squeeze" i686 中(换句话说,在 32 位架构中)。我一直在尝试使用 Oracle JDK 8 64 位。我已经 运行 execstack over libOasisEMSec.so,我再次从这个站点 http://rpm.pbone.net/index.php3/stat/4/idpl/27875140/dir/opensuse_13.x/com/compat-32bit-2010.1.31-19.1.2.x86_64.rpm.html 下载了 64 位版本。编译没问题,但是执行报如下错误:

# java -Djava.library.path=/var/www/vhosts/myvirtualshop.com/lib/Digest/linux -classpath /var/www/vhosts/myvirtualshop.com/lib/Digest/linux:/var/www/vhosts/myvirtualshop.com/lib/Digest/linux exampledigest

Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /var/www/vhosts/myvirtualshop.com/lib/Digest/linux/libOasisEMSec.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /var/www/vhosts/myvirtualshop.com/lib/Digest/linux/libOasisEMSec.so: /var/www/vhosts/myvirtualshop.com/lib/Digest/linux/libOasisEMSec.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at OasisEMSecImp.<clinit>(OasisEMSecImp.java:9)
        at exampledigest.main(exampledigest.java:36)

这里的大问题是:我如何在 Debian Linux 64 位环境中 运行 这个旧的 Java 二进制文件?

要在 64 位系统上运行 运行 32 位程序,您需要启用 Multiarch:

 apt-get install ia32-libs -y

参见示例 32bit firefox/thunderbird on debian amd64

如果您需要旧版本的 Sun Java

您需要从 http://www.oracle.com/technetwork/java/archive-139210.html 下载它,自行解压缩,并更新您的 $PATH 以指向它。可能还有你的 $JAVA_HOME 一些工具。

The oficial Installation Notes for Linux

  1. 确保设置了执行权限运行这个命令:

    chmod    +x j2re-1_4_2_<version>-linux-i586.bin
    
  2. 运行 自解压二进制文件。

    执行下载的文件,前面加上它的路径。为了 例如,如果文件在当前目录中,则在其前面加上“ ./"(如果“.”不在 PATH 环境变量中则需要):

    ./j2re-1_4_2_<version>-linux-i586.bin
    

Note about System Preferences: By default, the installation script configures the system such that the backing store for system preferences is created inside the Java 2 Runtime Environment's installation directory. If the J2RE is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines. As an alternative, root users can use the -localinstall option when running the installation script, as in this example:

j2re-1_4_2_-linux-i586.bin -localinstall This option causes the system preferences to be stored in the /etc directory from which they can be shared only by VMs running on the local machine. You must be root user for the -localinstall option to work.