Issue
I've fallen (kind of) once again in an issue that I already solved months ago. I need to run a Java virtual POS that, according to the official manual, needs the Java VM 1.4.2, but the environment is Debian GNU/Linux 7 "Wheezy" amd64, and I haven't found that expecific version for that architecture (nor Solaris amd64 or IA64 fit to my case). That Virtual POS has been working perfectly fine, but in Debian GNU/Linux 6 "Squeeze" i686 (in other words, in a 32bits architecture). I've been trying to use the Oracle JDK 8 64bits. I've run execstack over libOasisEMSec.so, which I downloaded once again, but in 64 bits, from this site 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. The compilation is fine, but the execution gives me the following error:
# 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)
The big question here is: how can I run this old Java binary, in a Debian Linux 64bits environment?
Solution
To run 32 bit programms on 64 bit system you need to enable Multiarch:
apt-get install ia32-libs -y
See example 32bit firefox/thunderbird on debian amd64
If you need an older version of Sun Java
You need to download it from http://www.oracle.com/technetwork/java/archive-139210.html, unpack it yourself, and update your $PATH
to point to it. Possibly also your $JAVA_HOME
for some tooling.
The oficial Installation Notes for Linux
Make sure that execute permissions are set Run this command:
chmod +x j2re-1_4_2_<version>-linux-i586.bin
Run the self-extracting binary.
Execute the downloaded file, prepended by the path to it. For example, if the file is in the current directory, prepend it with " ./" (necessary if " ." is not in the PATH environment variable):
./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.
Answered By - Valeriy Solovyov