编写高质量代码建议17代码错误调试
错误1:
com.intellij.rt.execution.application.AppMain advicetest.advice17.Client
Exception in thread "main" java.lang.IllegalStateException: 找不到目录: ./bin
at com.sun.tools.javac.main.Main.error(Main.java:173)
at com.sun.tools.javac.main.Main.checkDirectory(Main.java:317)
at com.sun.tools.javac.main.Main.processArgs(Main.java:257)
at com.sun.tools.javac.main.Main.compile(Main.java:383)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at advicetest.advice17.Client.main(Client.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
原因是bin目录不存在。
换成./,错误提示信息如下:
Exception in thread "main" java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at advicetest.advice17.Client.main(Client.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
类文件已经生成D:\advice\Hello.class。但是intellij的maven项目的编译目录是target目录下,所以找不到Hello类文件。
换成下面即可./target/test-classes