アプレットを実行しようとすると、次の例外が発生します。
java.lang.reflect.InvocationTargetException
at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: Class sun.plugin2.applet.Plugin2Manager$12 can not access a member of class MyApplet with modifiers ""
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.IllegalAccessException: Class sun.plugin2.applet.Plugin2Manager$12 can not access a member of class MyApplet with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 9 more
例外:java.lang.reflect.InvocationTargetException
アプレットコード:
import javax.swing.*;
import java.awt.*;
class MyApplet extends JApplet {
public JFrame frame;
public JPanel panel;
public JButton button;
public void init() {
frame = new JFrame();
panel = new JPanel();
button = new JButton("click me ");
panel.setBackground(Color.RED);
panel.add(button);
frame.add(panel);
frame.setSize(300,300);
frame.setVisible(true);
}
}
HTMLファイル:
<applet code="MyApplet" codebase="AppletPackage" archive="JAR.jar" height="800" width="800">
JAR.jarには、クラスMyAppletを含むAppletPackageという名前のパッケージが含まれています。また、自動的に追加されたマニフェストファイルも含まれています。
何が問題ですか ?