小程序运行失败

发布于 11-29 04:43 字数 639 浏览 1 评论 0原文

当我尝试运行小程序时,出现异常:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一念一轮回2024-12-06 04:43:28

将您的小程序类设置为 Public 即可。就是这样

Make your applet class Public that should do it. That's it

恰似旧人归2024-12-06 04:43:27
class MyApplet ...

将导致 InitationTargetException,而..

public class MyApplet ...

..应该没问题。

class MyApplet ...

Will cause an InvocationTargetException, whereas..

public class MyApplet ...

..should be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文