类在D:\IceDemo\bin下面,完整目录是D:\IceDemo\bin\demo\ice\helloworld\server\HelloWorld.class
使用到了一个外部的ICE.jar,放在D:\IceDemo\lib\目录下
我在D:\IceDemo\bin目录下执行
java demo.ice.helloworld.server.HelloServer
然后报错:
Exception in thread "main " java.lang.NoClassDefFoundError: Ice/LocalException
然后修改了classpath
@echo off
set classpath=%classpath%;D:\IceDemo\bin;D:\IceDemo\bin;D:\IceDemo\bin\demo\ice\helloworld\server\HelloWorld.class
echo classpath: %classpath%
java HelloWorld
当前的classpath为: .;D:\IceDemo\bin;D:\IceDemo\bin\demo\ice\helloworld\server\HelloServer.class;D:\IceDemo\bin\Ice.jar
报错如下:
D:\IceDemo\bin\demo\ice\helloworld\server> java HelloWorld
Exception in thread "main " java.lang.NoClassDefFoundError: helloworld (wrong na
me: demo/ice/helloworld/server/helloworld)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
------解决方法--------------------------------------------------------
D:\IceDemo\bin\demo\ice\helloworld\server> java HelloWorld
这个是错误的。
应该是这样:
java demo.ice.helloworld.server.HelloServer