小程序运行失败
当我尝试运行小程序时,出现异常:
java.lang.reflect.InvocationTargetException
我读到调用错误是由于访问修饰符造成的:
http://download.oracle.com/javase/tutorial/reflect/member /ctorTrouble.html
并在堆栈跟踪中进一步阅读:
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException:
Class sun.plugin2.applet.Plugin2Manager$12 can not access
a member of class gui.TestWindow with modifiers ""
我认为访问修饰符没有任何问题,所以出于好奇,我将 public 修饰符放在所有字段和方法上那个班级,但是问题持续存在。我也有一个带有 0 个参数的公共构造函数,所以不可能是这样。
When I try to run an applet I get the Exception:
java.lang.reflect.InvocationTargetException
I read that the invocation error would be due to access modifiers:
http://download.oracle.com/javase/tutorial/reflect/member/ctorTrouble.html
and further down in the stack trace I read:
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException:
Class sun.plugin2.applet.Plugin2Manager$12 can not access
a member of class gui.TestWindow with modifiers ""
I didn't think I had any problems with access modifiers, so just out of curiosity I put the public modifier on all fields and methods in that class, but the problem persists. I do also have a constructor with 0 arguments that is public, so it can't be that.
将您的小程序类设置为 Public 即可。就是这样
Make your applet class Public that should do it. That's it