我試圖在瀏覽器中運行applet時遇到問題。我得到一個NullPointerException,我無法確定它出錯了。開放式移位Java Applet
這裏是堆棧跟蹤:
Java Plug-in 10.60.2.19
Using JRE version 1.7.0_60-b19 Java HotSpot(TM) Client VM
User home directory = C:\Users\Alexandru
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.lang.NullPointerException
at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)
at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)
at sun.awt.SunToolkit.getSystemEventQueueImpl(Unknown Source)
at java.awt.Toolkit.getEventQueue(Unknown Source)
at java.awt.EventQueue.invokeLater(Unknown Source)
at sun.awt.windows.WToolkit.windowsSettingChange(Unknown Source)
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
我得到這個後,我得到一個Quiz.class ClassNotFound的。
這裏是我的代碼:
<jsp:plugin type="applet" code="Quiz.class" codebase="../target/classes" width="500" height="280">
<jsp:fallback>
<p> Unable to load applet </p>
</jsp:fallback>
</jsp:plugin>
我試圖運行OpenShift雲服務的應用程序。我的服務器使用JBoss運行,它應該創建一個測驗並將其顯示在applet中。我已經創建了測驗,並且可以通過jsp將其顯示在瀏覽器中,但現在由於安全問題,現在我試圖在applet中顯示它。
這裏是我的applet代碼(這個小程序是僅用於測試,我應設法以顯示它的測驗後,我解決了這個問題):
package models;
import java.applet.Applet;
import java.awt.Graphics;
public class Quiz extends Applet{
/**
*
*/
private static final long serialVersionUID = 1L;
public void paint(Graphics g)
{
g.drawString("My applet",400,200);
}
}
我的項目是基於Maven的,我想這很重要。我嘗試從我的applet中將編譯後的類添加到jar中,並在運行時使用Maven插件將其添加到webapp文件夾中,使用此示例Maven - Copy Some Dependency JARs into warSourceDirectory但它沒有幫助。我也試圖直接使用這個插件編譯類WebApp文件夾:
<pluginRepositories>
<pluginRepository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
與此配置文件:
<profile>
<id>copy</id>
<build>
<plugins>
<plugin>
<groupId>com.github.goldin</groupId>
<artifactId>copy-maven-plugin</artifactId>
<version>0.2.5</version>
<executions>
<execution>
<id>create-archive</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<resources>
<resource>
<targetPath>${project.build.outputDirectory}/work/webapp/WEB-INF/classes/</targetPath>
<directory>${project.basedir}/src/main/webapp</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
,但它也不能工作。還有其他建議嗎?
代碼庫是一個HTTP路徑,與Maven目錄佈局無關。 – chrylis