Jogl Applet Beginning

So this may be a newbie question but I’m having a little trouble with JOGL Applets and deployment. I’ve read over a bunch of other posts and some seem dated and I just don’t get others. If someone is willing to help and answer my dumb questions I’d appreciate it.

To start I’m able to get JOGL applets to work in eclipse. Here is a basic class that I’m trying to deploy.


import java.applet.Applet;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;

import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.FPSAnimator;

public class AppletLauncherJogl extends Applet implements GLEventListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5349107458641586294L;

    public void init() {
        GLProfile glp = GLProfile.getDefault();
        GLCapabilities caps = new GLCapabilities(glp);
        GLCanvas canvas = new GLCanvas(caps);
        
        canvas.setSize(400, 400);
        canvas.setVisible(true);
        add(canvas);
        
        canvas.addGLEventListener(new AppletLauncherJogl());
        
        this.start();

        Animator animator = new FPSAnimator(canvas, 60);
        animator.add(canvas);
        animator.start();
    }

    @Override
    public void display(GLAutoDrawable drawable) {
        update();
        render(drawable);
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
    }

    @Override
    public void init(GLAutoDrawable drawable) {
    }

    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    }

    private void update() {

    }

    private void render(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        gl.glClear(GL.GL_COLOR_BUFFER_BIT);

        gl.glBegin(GL.GL_TRIANGLES);
	        gl.glColor3f(1, 0, 0);
	        
	        gl.glVertex3d(0, 0, 0);
	        gl.glVertex3d(0, 0.5, 0);
	        gl.glVertex3d(0.5, 0, 0);
        gl.glEnd();
    }
}


As far as deployment I’ll start by saying I’ve been trying a lot.

This works
https://jogl-demos.dev.java.net/applettest-jnlp.html

This doesn’t work
https://jogl-demos.dev.java.net/applettest.html

From what I gather the best way to do this is to use the JNLPAppletLauncher
https://applet-launcher.dev.java.net/

So I exported the project from Eclipse to get a jar (File->export: Java->Jar File)

And they tried to use this html


<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
      width=600
      height=400
      archive="http://download.java.net/media/applet-launcher/applet-launcher.jar,
	           http://download.java.net/media/jogl/jsr-231-2.x-webstart/nativewindow.all.jar,
               http://download.java.net/media/jogl/jsr-231-2.x-webstart/jogl.all.jar,
               http://download.java.net/media/gluegen/webstart-2.x/gluegen-rt.jar,
               MyURL/AppletLauncherJogl.jar">
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" value="AppletLauncherJogl">
   <param name="subapplet.displayname" value="AppletLauncherJogl">
   <param name="noddraw.check" value="true">
   <param name="progressbar" value="true">
   <param name="jnlpNumExtensions" value="1">
   <param name="jnlpExtension1"
          value="http://download.java.net/media/jogl/jsr-231-2.x-webstart/jogl-core.jnlp">
   <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
   <param name="jnlp_href" value="MyURL/AppletLauncherJogl.jnlp">
</applet>

With this JNLP file


<jnlp href="MyURL/AppletLauncherJogl.jnlp">
m<?xml version="1.0" encoding="utf-8"?>
	<information>
		<title>Title Stuff</title>
		<vendor>Made by Me</vendor>
		<homepage href="MyURL/"/>
		<description>AppletLauncherJogl</description>
		<description kind="short">It Does stuff</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="MyURL/AppletLauncherJogl.jar" main="true"/>
		<extension name="jogl-all-awt" href="http://download.java.net/media/jogl/jsr-231-2.x-webstart/jogl-all-awt.jnlp" />
	</resources>

	<applet-desc
		name="AppletLauncherJogl"
		main-class="AppletLauncherJogl"
		width="600" 
		height="400">
	</applet-desc>
  
</jnlp>

When this runs I just get a blank window. I have my .jar and .jnlp file in the main directory of my webpage. I’ve tired many browsers WinExplore/Chrome/Firefox on in Win7.

If anyone sees any errors or can help me out I’d really appreciate it. I normally do OpenGL games in c++ but I made some neat learning tools that I’d like to share online. Thanks.

JOGL is here, your links are outdated:
http://jogamp.org/jogl/www/

Ok so I updated my files with that new link and I still get nothing. I’m trying to do this on google sites and I figured that may be the problem so I tried to run it on my local machine. But now I get this error

exception: JNLP file error: file:/C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/AppletLauncherJogl.jnlp. Please make sure the file exists and check if “codebase” and “href” in the JNLP file are correct

when I use these. The html, jnlp, and jar are all in the same directory.


<applet 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,
               file:///C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/AppletLauncherJogl.jar">
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" value="AppletLauncherJogl">
   <param name="subapplet.displayname" value="AppletLauncherJogl">
   <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">
   <param name="jnlp_href" value="file:///C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/AppletLauncherJogl.jnlp">
</applet>


<?xml version="1.0" encoding="utf-8"?>
<jnlp href="file:///C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/AppletLauncherJogl">
  <information>
    <title>AppletLauncherJogl</title>
    <vendor>AppletLauncherJogl</vendor>
    <homepage href="file:///C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/"/>
    <description>AppletLauncherJogl</description>
    <description kind="short">AppletLauncherJogl</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="file:///C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/AppletLauncherJogl.jar" main="true"/>
      <extension name="jogl-all-awt" href="http://jogamp.org/deployment/webstart/jogl-all-awt.jnlp" />
    </resources>

  <applet-desc 
      name="AppletLauncherJogl"
      main-class="AppletLauncherJogl"
      width="640" 
      height="480">
  </applet-desc>
</jnlp>

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,
               file:///C:/Users/Stephen/Documents/JAVA/AppletLauncherJogl/AppletLauncherJogl.jar">

JNLP does not support local access “file:///C:/”, it is quite obvious. Put this JAR online and use a real URL, not a path pointing to a local resource.

Well I replaced the references with the file references online and I still get nothing. From what I’ve read I feel like my code is now correct. I’m thinking that it is not possible to host this on google sites. Does anyone have any other suggestions? I’m not too familiar with html and jnlp, but is there a way to debug? If anyone is willing to try to run this code for me I’d appreciate it. Everything is posted above. If it works on something other than google sites I’ll just get a domain and storage and then go from there, I just don’t want to spend any money until I know it works.

Does it have to be JOGL? I’ve tried the LWJGL applet system & it works (it’s what Minecraft uses). If you need openGL in an applet perhaps LWJGL might be an easier choice?

disclaimer No insult or injury to JOGL or any users of JOGL is intended by the author of this post. No debate regarding the relative merits of JOGL to any other java-based openGL implementation will be entered into.

FWIW, Scar can build your project and generate the JNLP for you, signed JARs and everything.

[quote]JNLP does not support local access
[/quote]
Yes it can.

I think he saying its pointless with JNLP

but that is alot of ‘/’ characters

It is supposed to be like that.

It is an URL, read it like:
file://localhost/C:/

When I print out the toString values of URLS I get
file:C:/… (Windows 7)
this is from URLS passed to a ClassLoader.
Currently I havnt had any problems with this style of URL.
Also works fine on Mac except without the “C:”
just an extra “/”

edit: done a quick test of the system class loader this is what i got


		URL u[] = ((URLClassLoader)ClassLoader.getSystemClassLoader()).getURLs();
		for (int i = 0; i < u.length; i++) {
			System.out.println(u[i]);
		}

file:/C:/Users/…
file:/C:/Users/…blahblah
file:/C:/Users/…blahblahablah

also tested with “///” seems to work fine aswell (on windows), you learn something new everyday.

yet in order to get stuff working with mac I have had to do something like this


new URL("file:" + System.getProperty("java.io.tmpdir"));

not exactly that, as its customary to test for a file seperator on the end of the tmpdir.

“file:” seemed to be the only string that would work, to be OS independant.

[quote]Does it have to be JOGL? I’ve tried the LWJGL applet system & it works
[/quote]
I’ll look into that, but now I’m curious why I can’t get JOGL to work.

Is there something wrong with my actual class and the way I exported the jar file? Am I selecting the main class wrong in my html/jnlp? Those are the only two things I can think of. The way I did this was in Eclipse and just did File->export, the JAVA->Jar file, then in that pop up window all I do is select the project and give it a name, I don’t do anything else. Is there something else I’m supposed to do?

Thanks again for all the help.

As far as the local access, I don’t really care too much about that, I was just trying something different because I only am using google sites. But thanks for the info anyways. Always good to learn something new.

No you cannot access to the local file system by using simply absolute path or URI, it has to be an URL, you have to use the local loop, a local network interface. I checked it in the documentation of Java Web Start when I wanted to use JNLP to install a game from a CD.

No we’ll solve your problem without switching to this library.

I have found what is wrong. You’re affected by the bug 411 of JOGL 2, Sven has just fixed it in applets today. Update your JARs and your native libraries (.so, DLL, .jnilib). There is no need of using another OpenGL binding. JOGL 2 is still in beta, sorry, we do what we can.

Thanks a lot, I really appreciate your help. I replaced the files with the new version and that seemed to fixed the problem, at least at first. I’m a little confused by what is going on now. Sometime my applet will load fine, (a little slow but it loads) but other times I get this error. I’m not really sure what could be wrong, but I do know my jnlp doesn’t have 100+ lines so I’m thinking it may be with one of the linked files. Any thoughts? This may be something that should be in another thread, so let me know if I should move. Thanks again.

Here a link to the applet
https://sites.google.com/site/astrodynamics101/orbital-elements

JNLParseException[ Could not parse launch file. Error at line 126.]
	at com.sun.javaws.jnl.XMLFormat.throwNewException(Unknown Source)
	at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
	at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
	at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
	at sun.plugin2.main.client.PluginMain.access$300(Unknown Source)
	at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Error while initializing manager: JNLParseException[ Could not parse launch file. Error at line 126.], bail out

[quote] I checked it in the documentation of Java Web Start when I wanted to use JNLP to install a game from a CD.
[/quote]
http://today.java.net/pub/a/today/2008/07/10/distributing-web-start-via-cd-rom.html

[quote]Cross-Platform Issues

The application launcher above relies on some Windows-specific features and therefore the runs only on Windows.
[/quote]
It is the useless…

p0pes, please show me the line 126.

Uh, I don’t have a line 126 in jnlp file, unless this line numbering includes files it loads. But here is my file anyways.


<?xml version="1.0" encoding="utf-8"?>
<jnlp href="https://sites.google.com/site/astrodynamics101/ElementLearner.jnlp">
<information>
     <title>ElementLearner</title>
     <vendor>ElementLearner</vendor>
     <homepage href="https://sites.google.com/site/astrodynamics101/"/>
     <description>ElementLearner</description>
     <description kind="short">ElementLearner</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="https://sites.google.com/site/astrodynamics101/ElementLearner.jar" main="true"/>
     <extension name="jogl-all-awt" href="http://jogamp.org/deployment/webstart/jogl-all-awt.jnlp" />
     </resources>

<applet-desc 
     name="ElementLearner"
     main-class="ElementLearner"
     width="800" 
     height="800">
</applet-desc>

</jnlp>

Also,

[quote]http://today.java.net/pub/a/today/2008/07/10/distributing-web-start-via-cd-rom.html
[/quote]
is something completely different right? My way should be cross-platform? I don’t have a Mac so I haven’t been able to test.

http://jogamp.org/deployment/webstart/jogl-all-awt.jnlp seems to work on my computer, I use Linux.

OK, without changing anything from before my applet will work only if is the first thing started when I start up my computer. If I hit refresh or go to another site then return I get an error. It almost seems random but I will get one of these errors.


exception: Found unsigned entry in resource: https://sites.google.com/site/astrodynamics101/ElementLearner.jar.
com.sun.deploy.net.JARSigningException: Found unsigned entry in resource: https://sites.google.com/site/astrodynamics101/ElementLearner.jar
	at com.sun.javaws.security.SigningInfo.getCommonCodeSignersForJar(Unknown Source)
	at com.sun.javaws.security.SigningInfo.check(Unknown Source)
	at com.sun.javaws.LaunchDownload.checkSignedResourcesHelper(Unknown Source)
	at com.sun.javaws.LaunchDownload.checkSignedResources(Unknown Source)
	at sun.plugin2.applet.JNLP2Manager.prepareLaunchFile(Unknown Source)
	at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Exception: com.sun.deploy.net.JARSigningException: Found unsigned entry in resource: https://sites.google.com/site/astrodynamics101/ElementLearner.jar

or


JNLParseException[ Could not parse launch file. Error at line 126.]
	at com.sun.javaws.jnl.XMLFormat.throwNewException(Unknown Source)
	at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
	at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
	at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
	at sun.plugin2.main.client.PluginMain.access$300(Unknown Source)
	at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Error while initializing manager: JNLParseException[ Could not parse launch file. Error at line 126.], bail out


or


Exception in thread "thread applet-ElementLearner-3" java.lang.ExceptionInInitializerError
    at ElementLearner.init(ElementLearner.java:74)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.media.opengl.GLException: No profile available: [GL2, GL3bc, GL4bc, GL2GL3, GL3, GL4, GL2ES2, GLES2, GL2ES1, GLES1], GLAvailability[Native[GL4bc false, GL4 false, GL3bc false, GL3 false, GL2 false, GL2ES1 false, GLES1 false, GL2ES2 false, GLES2 false], Profiles[, default null]]
    at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1008)
    ... 3 more

I’m at a little loss for whats going on because this http://jogamp.org/jogl-demos/www/applettest-jnlp.html always works. I’m thinking I may be doing something wrong in my actually class. Is the source code for the gears demo applet available anywhere? I’d like to try to build that in eclipse, then export and then host it myself to see if I get any errors.

[quote]It is the useless…
[/quote]
Not really, but I was just proving my point you can use local. You could probably can modify that to support Linux too. Have autorun file for each OS(I’m guessing they are all different) run the correct file.