Reputation: 57702
I am developing an applet for some OpenGL ES stuff using JOGL. In eclipse I can start the applet but in the browser I have trouble because the java console prints a NoSuchMethodError in my line where I create an instance of GLCanvas.
GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(8);
glCanvas = new GLCanvas(caps); // throws NoSuchMethodError
The 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)
I created a jar with and without the jogl libs (jogl, gluegen, nativewindow and newt) but it just didn't work. Does someone have an idea?
My 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>
My applet tag:
<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>
The complete console log: http://pastebin.com/xjk84pTV (the log is partly translated into german, not sure how I can change that...)
update
Providing the basic jogl libraries by myself doesn't change anything...
<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>
I also tried loading the applet this way but nothing changed...
<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>
Upvotes: 2
Views: 1377
Reputation: 57702
I found the reason: The reason was a messed up usage of libraries. The libraries I have used were given by another project and it seems that they are older than the current version. That means that the libraries downloaded by the applet uses another API which results in the exception.
Here is my "solution":
Java code:
GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
GLCapabilitiesImmutable caps = new GLCapabilities(glp);
glCanvas = new GLCanvas(caps);
Calling the applet in 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>
And finally my 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>
Upvotes: 1
Reputation: 3305
Quick thing to check, is the version of the JRE you're using in Eclipse the same as the version of the JRE running in your browser?
Upvotes: 2