package cn.togeek.job; public class Test {
public static void main(String[] args) throws Exception {
System.out.println("Hello,world!");
}
}
javac Test.java
运行正常
接着运行
java 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)
这个时候:
../../.. 然后运行,OK好了
这么运行也是OK的 E:\src>java -cp ./main/java/ cn.togeek.job.Test
Hello,world! 在
E:\src>java -cp E:/src/main/java/ cn.togeek.job.Test
Hello,world! 这样在所有文件夹下都可以运行了!