JOGL + Applets

Hello there,

Im looking to do some browser based stuff with JOGL, im not to farmiliar with Java and JOGL but from what ive read it is possible, even if its not done that often. I was wondering if there are any good tutorials or info on this sort of stuff?

Also for some reason why i try to run any compiled files from the browser it locks up my browser and uses memory quite fast. I tried this using the Netbean plugin for JOGL and adding to the simple application project:


import java.applet.*;

public class SimpleJOGL extends Applet implements GLEventListener

It compiled and built fine but when i try and call it in the browser using the following:

<applet align=middle code="SimpleJOGL.class" width=256 height=256>

Anyone know why that would happen? i looked on the forums and can see people suffering with this problem back in Sep 2004 time but then it seems to be fixed…

I know this is kinda two questions in one, but any answers to either would help…

Well part of this post is to bump!

but also thought i would elaborate a bit more…

The error i keep getting when it breaks the browser is shown below.
Looks like it cant find class definitions for something… im guessing it cant find whatever JOGL stuff it needs…


Java Plug-in 1.6.0
Using JRE version 1.6.0 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings


----------------------------------------------------
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
p:   reload proxy configuration
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.NoClassDefFoundError: SimpleJOGL (wrong name: org/yourorghere/SimpleJOGL)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at sun.applet.AppletClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadCode(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.plugin.AppletViewer.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Currently have:

  • SimpleJOGL.class
  • Index.html

I then tried adding the following to that folder to see if it would help:

  • gluegen-rt.dll
  • jogl_awt.dll
  • jogl.dll
  • jogl_cg.dll
  • /lib/glugen-rt.jar
  • /lib/jogl.jar

Still doesnt work :frowning:

Can anyone let me know what you need to get JOGL running in a browser, as just the class by itself doesnt seem to do it…

There are several things to consider:

  • java is package based, so you most probably missing the package name (e.g. org.yourorghere.SimpleJOGL)
  • you have to package your class in a jar with a directory structure following the packages(e.g. jar content = org/yourorghere/SimpleJOGL.class)
  • you have to implement a correct lifecycle for an applet, see: the applet tutorial (there might be better tutorials out ther, feel free to use google ;))
  • you have to setup your dependencies right (that’s a bit difficult for JOGL)
  • hardware access only works with signed applets.

the last two points are addressed by the JOGLAppletLauncher, see

.JAR files are effectivly Zip files arnt they?

How do i get my .class into a .jar file then?
If the above question is more of a newbie question and belongs in other forums here please let me know and i will ask there…

When you say “Set up your dependancies” could you be a bit more specific on what sort of dependancies you are relating to…

Thanks for the links btw, reading them at the moment.

http://java.sun.com/docs/books/tutorial/deployment/jar/

Brilliant thanks guys!

ive now stopped it crashing and it loads the applet up, however its just a big white box at the moment, im looking into if i need to do anything else to make it run correctly, i read i dont have to sign MY jar file because the JOGL.jar and gen thingy are already signed, is this true or should i sign it?

Yes that’s correct. You’ll have to use the JOGLAppletLauncher and set your applet class as parameter “subapplet.classname”, like it is stated in the JOGLAppletLauncher javadoc or on the demopage.

Hello again!

Just got back in the office and tried what you mentioned, and now im getting the following error:

Error: Unable to install the native file locally

Is this down to a permissions issue on my browser or my computer, or is this down to something not being signed correctly?
Or something completely different?

Thanks again for any help you guys can offer!

after a while of searching i found this article on these forums:

http://www.java-gaming.org/forums/index.php?topic=15439.msg123000

I have looked through that and still am getting the problems, am i correct in thinking i require “gluegen-rt.dll” in the folder with all the JAR files?

No, you need gluegen-rt-natives-windows-i586.jar (for example) in the folder with the other jars.

ok thanks, im sure its already in there but will check when i get back to the office later

Hello again,

Kinda sorry to ressurect this thread, ive been off and read up some more on java and applets in general.

After looking through the applet tutorial that you get with JOGL they are using a standard Applet class opposed to the JOGLappletlauncher class.

Ive signed my jar file, and it loads up in the browser fine, java loading splash screen comes up, and asks if i wish to allow the content to run. I then say yes, and it finishes loading but the applet just goes all white, whereas it should have a spinning cube in it.

These are the following procedures i did:

  • extend my main class from Applet class
  • build my jar file
  • add jogl.jar, gluegen-rt.jar to the folder (ive also added gluegen-rt-natives-windows-i586.jar, although it doesnt seem to make much difference)
  • created an applet html page with the following code:
<applet code="Engine.Init.class"
      width=800
      height=600
      codebase=""
      archive="CoreFramework.jar, gluegen-rt.jar, jogl.jar">
</applet>
  • Signed the CoreFramework.jar file, says its valid for 6 months.
  • Ran applet in webpage

Just comes up with a white box, but no errors in the java console, so its like its running but just not rendering anything…

Also is there any way to set 2 codebases as i want gluegen/jogl files in lib folder and my jar file in the root, but it wouldnt find it whenever i tried to seperate them up…

Please look at the javadoc for the JOGLAppletLauncher class and the JOGL applet test on the jogl-demos web site. These show how to use the JOGLAppletLauncher in conjunction with the tag to launch your applet. Once you’ve looked this over please post if you have more questions.

You can reference multiple locations with relative paths off the same codebase: for example, jogl.jar, lib/myengine.jar. However, I don’t think (for security reasons) that you can specify multiple codebases to the tag.

Thanks, ive already looked over most of the documentation there, if possible i dont wish to use the JOGLappletlauncher, i would rather use the built in Java one, purely because i may not use JOGL as the renderer, although the option is there…

If it is not possible to get the applet running JOGL without using a JOGLappletlauncher class then i will have to rethink things, however it doesnt look like that is the case from the demos and docs i have read…

  • Edited to update situation…

When using the JOGLAppletLauncher or standard Applet, it still brings up a white area, with nothing happening :frowning:

Do i need to derive from JOGLAppletLauncher opposed to Applet in the code or anything, i tried to do it and it built fine, however it doesnt seem to do anything different, white page :frowning: it works fine as a normal application though spinny cube with pretty colours…

Also im not sure if it matters, but as it stands my entry code is this:

package Main;
import Engine.Core.*;
import java.applet.*;

public class Entry extends Applet
{        
    public static void main(String[] args)
    {      
        // Renderer JOGL : 1
        BaseEngine beEngine = new BaseEngine(1);
    }
}

as it extends the Applet does it NEED to have overridden init(), start(), end() functions or whatever?

So that way when you init() it runs your code then runs the applet code as well, or does it somehow just turn whatever you derive it from into an applet?

I tried giving my entry class init() and other functions then creating a new entry() and running init() opposed to just creating the engine obj, still worked as an application, just not as an applet :frowning:

You need to subclass Applet and use the JOGLAppletLauncher. See the demos.applets.GearsApplet example in the jogl-demos workspace, in particular how it differs in structure from the Gears application. You should also probably read some background material on applets.

Yeah i checked all that stuff before, one VITAL piece of information that i was missing, well wasnt explicitly mentioned…

As an applet you dont use static main() you use init() start() etc…

I was just under the impression that you had to add in these as well as your main call, just tried to do it without main and with init() instead and all worked GREAT!

Well, not too great…

got a few outstanding problems:

  • Works in IE, crashes in FF, says that it cant find the JOGLAppletLauncher class, then dies a death.
  • Loads up in its own window opposed to running within the applet, so it loads up a new window of whatever width/height i give it, which isnt really what i wanted.

I remember reading that there were issues with the TalkBack service or something relating to it, i couldnt find it running on my system, but maybe i wasnt looking in the right place. Also i dont know why it would load up in its own window opposed to the given applet window like the demo with the gears does online. As i pretty much ripped the code from that to do the original test.

Well, you definitely need to read some background about applets… so here are some hints…

Applet are meant to behave nicely within their browser, that’s why you have to follow the init(), start() stop() and destroy() pattern.

An Applet is a general container (like JFrame) , so your GLCanvas should be added into it (let’s say ifrom the init() method).

Than the animator should get started from the applet.start() method, and stopped each time stop() is invoked (may happen many times, for example in FF when the user switches navigation tabs).

Hope it helps.

Lilian :slight_smile:

All info helps!

I think the reason it as opening in its own window was because i was using a frame opposed to using the applets container, so im changing my code for that…

Will keep plodding on and post if i get any more problems!
thanks again,

Got it running GREAT in the browser now, i just wrote in applet init code onto my window class, so if its an applet it will put itself into the browser, otherwise it will initilize itself in its own frame as an application…

Still breaks in FF though which is a pain… it keeps saying that its unable to find the JOGLAppletLauncher, as i mentioned before. However all the .jar files are in place…