java - 带有 JNLP 的 Jogl Applet 在 eclipse 中运行,但不在浏览器中运行

标签 java opengl-es applet jnlp jogl

我正在使用 JOGL 为一些 OpenGL ES 的东西开发一个小程序。在 Eclipse 中,我可以启动小程序,但在浏览器中我遇到了麻烦,因为 java 控制台在我创建 GLCanvas 实例的行中打印了 NoSuchMethodError。

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

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

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

异常(exception):

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 和 newt)的 jar,但它不起作用。 有人有想法吗?

我的 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>

我也尝试过以这种方式加载小程序,但没有任何改变......

<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>

最佳答案

快速检查一下,您在 Eclipse 中使用的 JRE 版本与浏览器中运行的 JRE 版本是否相同?

关于java - 带有 JNLP 的 Jogl Applet 在 eclipse 中运行,但不在浏览器中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4796676/

相关文章:

Java Applet,几个问题

Java游戏,游戏结束后根据用户命令重新启动

java - 如何显示其他布局?

Android OpenGL ES 不光栅化 - 矩阵乘法切换

Java 小程序 --> ClassNotFound 异常

html - 如何在 Chrome 中的 Java 小程序上显示 <div>

java - 从 Web 浏览器检测客户端 jre

java - 这个算法中变量 val 的目的是什么

ios - gpus_ReturnNotPermittedKillClient 应用后台运行时 MKMapView 抛出错误

ios - ofGrabber和ofTexture的像素格式关系