2011-01-25 99 views
2

我正在使用JOGL開發一些OpenGL ES東西的小程序。在eclipse中,我可以啓動applet,但在瀏覽器中遇到問題,因爲java控制檯在我的行中創建了一個NoSuchMethodError,我在其中創建了一個GLCanvas實例。JNLP Jogl Applet在eclipse中運行,但不在瀏覽器中

GLProfile glp = GLProfile.get(GLProfile.GL2ES2); 

GLCapabilities caps = new GLCapabilities(glp); 
caps.setSampleBuffers(true); 
caps.setNumSamples(8); 

glCanvas = new GLCanvas(caps); // throws NoSuchMethodError 

例外:

Exception in thread "thread applet-de.beuthhochschule.bachelor.martin.Benchmark-1" java.lang.NoSuchMethodError: javax.media.opengl.awt.GLCanvas.<init>(Ljavax/media/opengl/GLCapabilities;)V 
at de.beuthhochschule.bachelor.martin.Benchmark.initComponents(Benchmark.java:60) 
at de.beuthhochschule.bachelor.martin.Benchmark.init(Benchmark.java:42) 
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1620) 
at java.lang.Thread.run(Thread.java:662) 

我創建了一個罐子並沒有JOGL庫(JOGL,gluegen,NativeWindow並將蠑螈),但它只是沒有工作。 有人有想法嗎?

我的JNLP:

<?xml version="1.0" encoding="utf-8"?> 
<jnlp href="applet-benchmark.jnlp" codebase="."> 
 <information> 
   <title>WebGL-Benchmark</title> 
   <vendor>Martin Breuer</vendor> 
   <homepage href="http://localhost/"/> 
   <description>Native reference implementation</description> 
   <description kind="short">Reference implementation of the WebGL Benchmark</description> 
   <offline-allowed/> 
 </information> 

   <resources> 
     <j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+"/> 
     <property name="sun.java2d.noddraw" value="true"/> 
     <jar href="http://localhost/benchmark.jar" main="true"/> 
     <extension name="newt-all-awt" href="http://jogamp.org/deployment/webstart/newt-all-awt.jnlp" /> 
   </resources> 

 <applet-desc 
     name="WebGL-Benchmark" 
     main-class="de.beuthhochschule.bachelor.martin.Benchmark" 
     width="660" 
     height="500"> 
 </applet-desc> 
</jnlp> 

我的小程序標籤:

<applet codebase="." code="org.jdesktop.applet.util.JNLPAppletLauncher" width=600 height=400 
 archive="http://jogamp.org/deployment/util/applet-launcher.jar, 
          http://jogamp.org/deployment/webstart/nativewindow.all.jar, 
          http://jogamp.org/deployment/webstart/jogl.all.jar, 
          http://jogamp.org/deployment/webstart/gluegen-rt.jar, 
          http://jogamp.org/deployment/webstart/newt.all.jar"> 
   <param name="codebase_lookup" value="true"> 
   <param name="subapplet.classname" value="de.beuthhochschule.bachelor.martin.Benchmark"> 
   <param name="subapplet.displayname" value="WebGL-Benchmark"> 
   <param name="noddraw.check" value="true"> 
   <param name="progressbar" value="true"> 
   <param name="jnlpNumExtensions" value="1"> 
   <param name="jnlpExtension1" value="http://jogamp.org/deployment/webstart/jogl-core.jnlp"> 
   <param name="java_arguments" value="-Dsun.java2d.noddraw=true -Dsun.java2d.opengl=false"> 
   <param name="jnlp_href" value="http://localhost/applet-benchmark.jnlp"> 
</applet> 

完整的控制檯日誌:http://pastebin.com/xjk84pTV(日誌被部分翻譯成德文,不知道我怎樣才能改變這種狀況? )

更新

提供了基本的JOGL庫由我不會改變任何東西......

<resources> 
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+"/> 
    <property name="sun.java2d.noddraw" value="true"/> 
    <jar href="http://192.168.0.39/jogl.all.jar" /> 
    <jar href="http://192.168.0.39/newt.all.jar" /> 
    <jar href="http://192.168.0.39/nativewindow.all.jar" /> 
    <jar href="http://192.168.0.39/gluegen-rt.jar" /> 
    <jar href="http://192.168.0.39/benchmark.jar" main="true"/> 
    <extension name="newt-all-awt" href="http://jogamp.org/deployment/webstart/newt-all-awt.jnlp" /> 
</resources> 

我也嘗試加載applet的這種方式,但什麼都沒有改變......

<script src="http://www.java.com/js/deployJava.js"></script> 
<script type="text/javascript"> 
    var attributes = { 
     code:'de.beuthhochschule.bachelor.martin.Benchmark', 
     width:660, height:500 
    }; 
    var parameters = {jnlp_href: "applet-benchmark.jnlp"}; 
    var version = "1.6"; 
</script> 
<script type="text/javascript"> 
    deployJava.runApplet(attributes, parameters, version); 
</script> 
+0

啓用在Java控制檯中完全跟蹤,以便您可以ee在裝載過程中發生了什麼。這很可能是一個破碎的依賴關係。 – 2011-01-25 17:24:07

+0

日誌的Pastebin:http://pastebin.com/xjk84pTV所有我能看到的都很好,但我對此絕對是新的... – WarrenFaith 2011-01-25 17:26:34

回答

1

我發現原因:原因是圖書館使用混亂。我使用過的庫是由另一個項目給出的,看起來它們比當前版本舊。 這意味着applet下載的庫使用另一個導致異常的API。

這裏是我的 「解決方案」:

Java代碼:

GLProfile glp = GLProfile.get(GLProfile.GL2ES2); 
GLCapabilitiesImmutable caps = new GLCapabilities(glp); 
glCanvas = new GLCanvas(caps); 

調用HTML中的小程序:

<script type="text/javascript"> 
    var attributes = { 
     code:'de.beuthhochschule.bachelor.martin.Benchmark', 
     width:660, height:500 
    }; 
    var parameters = {jnlp_href: "applet-benchmark.jnlp"}; 
    var version = "1.6"; 
</script> 
<script type="text/javascript"> 
    deployJava.runApplet(attributes, parameters, version); 
</script> 

最後我JNLP:

<?xml version="1.0" encoding="utf-8"?> 
<jnlp href="applet-benchmark.jnlp"> 
    <information> 
     <title>WebGL-Benchmark</title> 
     <vendor>Martin Breuer</vendor> 
     <homepage href="http://192.168.0.39/" /> 
     <description>Native reference implementation</description> 
     <description kind="short">Reference implementation of the WebGL Benchmark</description> 
     <offline-allowed /> 
    </information> 

    <resources> 
     <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" /> 
     <property name="sun.java2d.noddraw" value="true" /> 
     <jar href="http://192.168.0.39/benchmark.jar" main="true" /> 
     <extension name="newt-all-awt" href="http://jogamp.org/deployment/webstart/newt-all-awt.jnlp" /> 
    </resources> 
    <applet-desc 
     name="WebGL-Benchmark" 
     main-class="de.beuthhochschule.bachelor.martin.Benchmark" 
     width="660" 
     height="500"> 
    </applet-desc> 
</jnlp> 
2

快速事情來檢查,是您在Eclipse中使用的JRE版本與在瀏覽器中運行的JRE版本相同嗎?

相關問題