java -cp /home/gjhawar/kafka/core/src/main/scala/examples TestProd.class
Exception in thread "main" java.lang.NoClassDefFoundError: TestProd/class
Caused by: java.lang.ClassNotFoundException: TestProd.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: TestProd.class. Program will exit.
为什么即使 Class 文件在此目录中,我也会收到此错误。我是否必须在 java 命令中也包含 jar 文件的路径?