I have 64-bit installation of CENTOS v6.5 final.
I have a 32-bit compiled Java application, which I created with WindowBuilder/SWT Designer/SWT/Composite inside Eclipse.
The application runs perfectly on Windows 7, where I created the Java application, from a Windows 7 command prompt:
java -cp "bin/*;lib/*" PkgNetAccelerator32.netAcceleratorApp
Inside the lib folder is swt.jar, and the Manifest.jar file that I automatically created. Yes, I downloaded the Linux version of swt.jar for use on CENTOS and placed that file in the /lib folder. I copied over the /bin and /lib and placed both folders at "/home/jmr/Documents/NetAccelerator/Java".
The problem that I receive the following error, when I try and start the Java application from a terminal window on my CENTOS box. The prompt is:
[jmr@sarah-linux Java]$ java -cp "bin/*;lib/*" PkgNetAccelerator32.netAcceleratorApp
Error: Could not find or load main class PkgNetAccelerator32.netAcceleratorApp
I do not have CLASSPATH or JAVA_HOME defined in my global environment variables list, although I do have the -cp option set. As stated above, swt.jar on the CENTOS box is the Linux version.
Here is the version information from Java:
[jmr@sarah-linux Java]$ java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.4.el6_5-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
The folder layout is fine.
[jmr@sarah-linux Java]$ ls -l bin
total 8
drwx------. 3 jmr jmr 4096 Dec 30 12:43 org
drwx------. 2 jmr jmr 4096 Dec 30 12:56 PkgNetAccelerator32
[jmr@sarah-linux Java]$ ls -l lib
total 1828
drwx------. 2 jmr jmr 4096 Dec 31 13:18 Linux
-rwxr-xr-x. 1 jmr jmr 7994 Dec 30 14:08 Manifest.jar
-rwxr-xr-x. 1 jmr jmr 124252 Dec 26 13:06 resty-0.3.2.jar
-rwxr-xr-x. 1 jmr jmr 1727233 Dec 31 13:18 swt.jar
drwx------. 2 jmr jmr 4096 Dec 31 13:18 Windows
[jmr@sarah-linux Java]$ ls bin/PkgNetAccelerator32/
netAcceleratorApp$1.class netAcceleratorApp.class
I am at a loss for how to fix the problem.
For whatever it is worth, I tried the following, but that gave the following error:
[jmr@sarah-linux Java]$ java -cp "bin/[An/*;lib/*" -jar lib/Manifest.jar PkgNetAccelerator32.netAcceleratorApp
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
Thoughts?
解决方案
On the Linux/Unix systems a classpath separator for Java programs is : (colon) instead of ; (semicolon). Change your Java call to:
java -cp "bin/*:lib/*" PkgNetAccelerator32.netAcceleratorApp