centos 不能运行java程序,在CENTOS上启动Java应用程序产生“无法找到或加载主类”...

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值