我正在尝试学习如何在 Windows 中仅使用命令行进行编译和运行。这是从根目录开始的目录树:
D:
ActivityOne
- classes
- com
-wat
-sampleapp
-students
StudentE.class
StudentMasterList.class (Main)
- src
-com
-wat
-sampleapp
-students
StudentE.java
StudentMasterList.java (Main)
问题是我现在对如何运行程序感到困惑。我尝试了两件事,两者都返回了不同的错误。
第一次尝试:
java -classpath classes StudentMasterList
回来:
Error: Could not find or load main class StudentMasterList
第二次尝试:
java -classpath classes/com/wat/sampleapp StudentMasterList
回来:
Exception in thread "main" java.lang.NoClassDefFoundError: StudentMasterList (wrongname: com/wat/sam
pleapp/StudentMasterList)
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)
下一次尝试后我感到困惑,对我应该如何运行主课有任何帮助吗?
更新:我应该在这个ActivityOne
级别运行我的所有命令。