我有一个JApplet在appletviewer运行时有效,但在Firefox或IE运行时无效。它显示一个空的矩形,显示“错误。点击查看详细信息。”单击它会弹出一个窗口,显示“Application Error.RuntimeException.java.lang.reflect.InvocationTargetException。”
我计划通过启动Hello world程序并添加完整applet的一部分来找到错误的来源,直到错误再次发生。相反,即使是Hello world程序也会产生错误。
编译器来自jdk1.7.0_45版本。对于此测试,命令和除编译器之外的所有文件都在Desktop文件夹中。下面粘贴了命令(减去数字签名),源代码和HTML。
set path=%path%;"C:\Program Files\Java\jdk1.7.0_45\bin"
javac sampleApplet.java
jar cvfm sampleApplet.jar sampleApplet.mf sampleApplet.class
(This is where I sign the code. I don't think that's the source of the error.)
sampleApplet.java中的文本
import java.awt.*;
import javax.swing.*;
public class sampleApplet extends JApplet {
public void paint(Graphics g) {
//super.paint(g);
g.drawString("Hello world.", 30, 30);
}
}
sampleApplet.mf中的文本
Main-Class: sampleApplet
sampleApplet.html中的文字
<html>
<head><title>sample applet</title></head>
<body>
Before applet.<br>
<applet code = "sampleApplet.class" archive = "sampleApplet.jar" width = "1020" height = "584">
</applet>
<br>After applet.<br>
</body>
</html>
编辑:转储线程堆栈很长。
Full thread dump Java HotSpot(TM) Client VM (24.45-b08 mixed mode, sharing):
"ConsoleTraceListener" daemon prio=4 tid=0x04d79400 nid=0xadc in Object.wait() [0x0626f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29cd7510> (a com.sun.deploy.uitoolkit.ui.ConsoleTraceListener$BoundedStringBuffer)
at java.lang.Object.wait(Object.java:503)
at com.sun.deploy.uitoolkit.ui.ConsoleTraceListener$ConsoleWriterThread.run(Unknown Source)
- locked <0x29cd7510> (a com.sun.deploy.uitoolkit.ui.ConsoleTraceListener$BoundedStringBuffer)
"TimerQueue" daemon prio=4 tid=0x04d7b000 nid=0x1194 waiting on condition [0x06aaf000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x24c10930> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.util.concurrent.DelayQueue.take(Unknown Source)
at javax.swing.TimerQueue.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
"TimerQueue" daemon prio=6 tid=0x04d7a800 nid=0xa50 waiting on condition [0x066ef000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x2a054870> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.util.concurrent.DelayQueue.take(Unknown Source)
at javax.swing.TimerQueue.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
"AWT-EventQueue-1" prio=6 tid=0x00ef9800 nid=0xca0 waiting on condition [0x0604e000]
java.lang.Thread.State: RUNNABLE
at com.sun.deploy.uitoolkit.ui.ConsoleHelper.dumpAllStacksImpl(Native Method)
at com.sun.deploy.uitoolkit.ui.ConsoleHelper.dumpAllStacks(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.ui.SwingConsoleWindow$3.actionPerformed(Unknown Source)
at javax.swing.JComponent$ActionStandin.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.KeyboardManager.fireBinding(Unknown Source)
at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)
at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
"JVM[id=1]-Heartbeat" daemon prio=6 tid=0x00efa400 nid=0x12ac in Object.wait() [0x0619f000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d72c10> (a sun.plugin2.main.client.PluginMain$Heartbeat)
at sun.plugin2.main.server.HeartbeatThread.run(Unknown Source)
- locked <0x29d72c10> (a sun.plugin2.main.client.PluginMain$Heartbeat)
"AWT-EventQueue-2" prio=4 tid=0x00efa000 nid=0x12b4 waiting on condition [0x05c3f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x29d72d68> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.awt.EventQueue.getNextEvent(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)
"Applet 1 LiveConnect Worker Thread" prio=4 tid=0x00ef7400 nid=0xc6c in Object.wait() [0x0570f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d72e68> (a java.lang.Object)
at java.lang.Object.wait(Object.java:503)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown Source)
- locked <0x29d72e68> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)
"Browser Side Object Cleanup Thread" prio=6 tid=0x00ef9400 nid=0x1054 in Object.wait() [0x05f1f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d72ef0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x29d72ef0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$BrowserSideObjectCleanupThread.run(Unknown Source)
"CacheCleanUpThread" daemon prio=6 tid=0x00ef8c00 nid=0xe58 in Object.wait() [0x05d1f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d72f10> (a com.sun.deploy.cache.CleanupThread)
at java.lang.Object.wait(Object.java:503)
at com.sun.deploy.cache.CleanupThread.run(Unknown Source)
- locked <0x29d72f10> (a com.sun.deploy.cache.CleanupThread)
"CacheMemoryCleanUpThread" daemon prio=6 tid=0x00ef8800 nid=0x1174 in Object.wait() [0x05b4f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d73000> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x29d73000> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at com.sun.deploy.cache.MemoryCache$LoadedResourceCleanupThread.run(Unknown Source)
"MemoryCache-DelayedCleanup" daemon prio=6 tid=0x00ef8000 nid=0x1320 in Object.wait() [0x05bcf000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d73090> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:503)
at java.util.TimerThread.mainLoop(Unknown Source)
- locked <0x29d73090> (a java.util.TaskQueue)
at java.util.TimerThread.run(Unknown Source)
"SysExecutionTheadCreator" daemon prio=6 tid=0x00ef5400 nid=0xd98 in Object.wait() [0x0580f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d730a0> (a sun.plugin.util.PluginSysUtil$SysExecutionThreadCreator)
at java.lang.Object.wait(Object.java:503)
at sun.plugin.util.PluginSysUtil$SysExecutionThreadCreator.run(Unknown Source)
- locked <0x29d730a0> (a sun.plugin.util.PluginSysUtil$SysExecutionThreadCreator)
"AWT-EventQueue-0" prio=6 tid=0x00ef7800 nid=0x12e0 waiting on condition [0x0597f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x29d73178> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.awt.EventQueue.getNextEvent(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)
"AWT-Windows" daemon prio=6 tid=0x00ef6c00 nid=0xc30 runnable [0x0113f000]
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
"AWT-Shutdown" prio=6 tid=0x00ef6800 nid=0x5c8 in Object.wait() [0x059ff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d732e0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:503)
at sun.awt.AWTAutoShutdown.run(Unknown Source)
- locked <0x29d732e0> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)
"Java2D Disposer" daemon prio=10 tid=0x00ef6000 nid=0x9bc in Object.wait() [0x0545f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d73370> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x29d73370> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
"Java Plug-In Pipe Worker Thread (Client-Side)" daemon prio=6 tid=0x00ef5c00 nid=0x7b4 runnable [0x0592f000]
java.lang.Thread.State: RUNNABLE
at sun.plugin2.os.windows.Windows.ReadFile0(Native Method)
at sun.plugin2.os.windows.Windows.ReadFile(Unknown Source)
at sun.plugin2.ipc.windows.WindowsNamedPipe.read(Unknown Source)
at sun.plugin2.message.transport.NamedPipeTransport$SerializerImpl.read(Unknown Source)
at sun.plugin2.message.transport.NamedPipeTransport$SerializerImpl.readByte(Unknown Source)
at sun.plugin2.message.AbstractSerializer.readInt(Unknown Source)
at sun.plugin2.message.transport.SerializingTransport.read(Unknown Source)
at sun.plugin2.message.Pipe$WorkerThread.run(Unknown Source)
"Timer-0" prio=6 tid=0x00ef4c00 nid=0xacc in Object.wait() [0x056bf000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d736d8> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:503)
at java.util.TimerThread.mainLoop(Unknown Source)
- locked <0x29d736d8> (a java.util.TaskQueue)
at java.util.TimerThread.run(Unknown Source)
"Thread-0" daemon prio=6 tid=0x00ef4800 nid=0x7e4 waiting on condition [0x054cf000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at com.sun.deploy.util.SecurityBaseline$4.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
"traceMsgQueueThread" daemon prio=6 tid=0x00ef4000 nid=0xe2c in Object.wait() [0x0501f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29cb1be8> (a java.util.ArrayList)
at java.lang.Object.wait(Object.java:503)
at com.sun.deploy.trace.Trace$TraceMsgQueueChecker.run(Unknown Source)
- locked <0x29cb1be8> (a java.util.ArrayList)
at java.lang.Thread.run(Unknown Source)
"Service Thread" daemon prio=6 tid=0x00ef3c00 nid=0xeac runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
"C1 CompilerThread0" daemon prio=10 tid=0x00efdc00 nid=0x850 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
"Attach Listener" daemon prio=10 tid=0x00ef3400 nid=0xc18 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" daemon prio=10 tid=0x00ef3000 nid=0x1130 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
"Finalizer" daemon prio=8 tid=0x00e88000 nid=0xe48 in Object.wait() [0x048ef000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d739d0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x29d739d0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
"Reference Handler" daemon prio=10 tid=0x00e83400 nid=0xf04 in Object.wait() [0x0481f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d73a58> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked <0x29d73a58> (a java.lang.ref.Reference$Lock)
"main" prio=6 tid=0x0065d800 nid=0x134 in Object.wait() [0x00d8f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29d73a60> (a sun.plugin2.message.Queue)
at sun.plugin2.message.Queue.waitForMessage(Unknown Source)
- locked <0x29d73a60> (a sun.plugin2.message.Queue)
at sun.plugin2.message.Pipe$1.run(Unknown Source)
at com.sun.deploy.util.Waiter$1.wait(Unknown Source)
at com.sun.deploy.util.Waiter.runAndWait(Unknown Source)
at sun.plugin2.message.Pipe.receive(Unknown Source)
at sun.plugin2.main.client.PluginMain.mainLoop(Unknown Source)
at sun.plugin2.main.client.PluginMain.run(Unknown Source)
at sun.plugin2.main.client.PluginMain.main(Unknown Source)
"VM Thread" prio=10 tid=0x00e7dc00 nid=0x13a0 runnable
"VM Periodic Task Thread" prio=10 tid=0x00f1d000 nid=0x124c waiting on condition
)
at sun.plugin2.main.client.PluginMain.run(Unknown Source)
at sun.plugin2.main.client.PluginMain.main(Unknown Source)
"VM Thread" prio=10 tid=0x00e7dc00 nid=0x13a0 runnable
"VM Periodic Task Thread" prio=10 tid=0x00f1d000 nid=0x124c waiting on condition