日期:2014-05-20  浏览次数:20838 次

dos下运行java程序 Package的问题
如下一段程序

package com.test.demo;



public class Test {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("!!!!!");
}

}
[color=#33CCCC][/color]

可以看到是在包com.test.demo下建立的java程序

问题来了 
在dos下运行如何调用了
如果单独如下运行的话
E:\study\MyEclipse 8.6\WorkPlace\javamail\src\com\test\demo>javac Test.java

E:\study\MyEclipse 8.6\WorkPlace\javamail\src\com\test\demo>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: com
/test/demo/Test)
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.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 sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

求教了 该以什么样的方式在dos下运行呢

------解决方案--------------------
探讨
路径很重要,因为你的类是: com.test.demo.Test

E:\study\MyEclipse 8.6\WorkPlace\javamail\src\com\test\demo>java -cp E:\study\MyEclipse 8.6\WorkPlace\javamail\src\ com.test.demo.Test


或者:
E:\study\MyEclipse……

------解决方案--------------------
探讨

路径很重要,因为你的类是: com.test.demo.Test

E:\study\MyEclipse 8.6\WorkPlace\javamail\src\com\test\demo>java -cp E:\study\MyEclipse 8.6\WorkPlace\javamail\src\ com.test.demo.Test


或者:
E:\study\MyEclips……