JOGL code compiles but will not run!! SOS!!

Howdy Y’all :slight_smile: -This is my first post!!
Programming has been a hobby of mine for about two years now, and I’m trying to make the leap from Actionscript to Java.

So I Installed jdk1.5.0_06, the latest one, in “C:\Program Files\Java\jdk1.5.0_06” on my WinXP machine and dropped “set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_06\bin” in autoexec.bat so my shell can see the bytecode utilities. All the native classes compile and run without complaint both from the command line and in Eclipse.

It all workes fine and dandy… then I try to install JOGL

“jogl.jar” and “jogl-natives-windows-i586.jar” have been downloaded to “C:\Program Files\Java\Extra\JOGL”, and I “unjared” the natives file in the same directory. I’ve read lots of opinions on Google about what to do next, and I interpereted that most of them wanted me to set my PATH and CLASSPATH variables, so I did it with the following commands:

“set CLASSPATH=.; C:\Program Files\Java\Extra\JOGL\jogl.jar”
“set PATH=%PATH%;C:\Program Files\Java\Extra\JOGL”

again in autoexec.bat. I figure that the JRE should be able to see the installation files now, so I test with a quickie program that’ll get the gears goin’ : “b.java”

"
import net.java.games.jogl.*;
class b {
public static void main(String[] args) {
GLCapabilities bob = new GLCapabilities();
GLCanvas Canvas = GLDrawableFactory.getFactory().createGLCanvas(bob);
}
}
"

Yes, its a pointless program… but remember it’s only a test :slight_smile:

Eclipse can see the jogl classes and says there are no errors in this program, and “javac” compiles this code just fine; but, the “java” command presents the following error paragraph in the console at runtime:

"Exception in thread “main” java.lang.UnsatisfiedLinkError: JAWT_GetAWT0
at net.java.games.jogl.impl.JAWTFactory.JAWT_GetAWT0(Native Method)
at net.java.games.jogl.impl.JAWTFactory.JAWT_GetAWT(JAWTFactory.java:37)
at net.java.games.jogl.impl.NativeLibLoader$1.run(NativeLibLoader.java:78)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.jogl.impl.NativeLibLoader.load(NativeLibLoader.java:58)
at net.java.games.jogl.impl.GLContext.(GLContext.java:52)
at net.java.games.jogl.impl.windows.WindowsGLContextFactory.createGLContext(WindowsGLContextFactory.java:147)
at net.java.games.jogl.GLCanvas.(GLCanvas.java:72)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:150)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:118)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:85)
at b.b.main(b.java:9)
"

I figure it’ll be awhile before I’ll be able to make sense of that mess on my own… so does anybody see where this installation has gone wrong?

My guess is that my JRE can see jogl.jar, but can’t read my library. If this is so, I can’t figure how I’d go about fixing it. I’m not about to go dropping files in my JRE installation or anything like that…

guess is that my JRE can see jogl.jar, but can’t read my library. If this is so, I can’t figure how I’d go about fixing it. I’m not about to go dropping files in my JRE installation or anything like that…

It’s not related to your problem, but you shouldn’t be touching autoexec.bat on Windows XP - that’s an ancient DOS thing, forget it exists.
The environment variables are set from the Advanced tab of the System Properties dialog that you get with you select Properties after right-clicking on My Computer. (see the Environment Variables button near the bottom of the tab.)

Again, stop using autoexec.bat you aren’t running DOS.
Also use of the CLASSPATH environment variable is discouraged. Adding a directory to the PATH environment variable just for the purposes of loading JNI libraries is also a bit strange - that’s the part that is failing below…

[quote] I figure that the JRE should be able to see the installation files now, so I test with a quickie program that’ll get the gears goin’ : “b.java”

"
import net.java.games.jogl.*;
class b {
public static void main(String[] args) {
GLCapabilities bob = new GLCapabilities();
GLCanvas Canvas = GLDrawableFactory.getFactory().createGLCanvas(bob);
}
}
"

Yes, its a pointless program… but remember it’s only a test :slight_smile:

Eclipse can see the jogl classes and says there are no errors in this program, and “javac” compiles this code just fine; but, the “java” command presents the following error paragraph in the console at runtime:

"Exception in thread “main” java.lang.UnsatisfiedLinkError: JAWT_GetAWT0
at net.java.games.jogl.impl.JAWTFactory.JAWT_GetAWT0(Native Method)
at net.java.games.jogl.impl.JAWTFactory.JAWT_GetAWT(JAWTFactory.java:37)
at net.java.games.jogl.impl.NativeLibLoader$1.run(NativeLibLoader.java:78)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.jogl.impl.NativeLibLoader.load(NativeLibLoader.java:58)
at net.java.games.jogl.impl.GLContext.(GLContext.java:52)
at net.java.games.jogl.impl.windows.WindowsGLContextFactory.createGLContext(WindowsGLContextFactory.java:147)
at net.java.games.jogl.GLCanvas.(GLCanvas.java:72)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:150)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:118)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:85)
at b.b.main(b.java:9)
"

I figure it’ll be awhile before I’ll be able to make sense of that mess on my own… so does anybody see where this installation has gone wrong?
[/quote]
javac and Eclipse don’t need to see the JNI libraries for JOGL to compile. They just need the class files.

try:
java -Djava.library.path=“C:\Program Files\Java\Extra\JOGL” YourClass

You could have put the JOGL classes and JNI libs in the jre\lib\ext folder… but that is not recommended because it will cause conflicts with programs that want to use different versions of JOGL. That’s also why it is not a good idea to add it to the CLASSPATH variable and PATH… you could end up breaking other stuff that uses a JOGL library that is packaged with the app.

It’s better to specify the classpath and library path specifically when running your app.

Scott

"
try:
java -Djava.library.path=“C:\Program Files\Java\Extra\JOGL” YourClass

It’s better to specify the classpath and library path specifically when running your app.
"
Thanks for your help swpalmer!! That was fast!!

OK, so I can set the CLASSPATH and JAVA.LIBRARY.PATH variables explicitly at runtime. If I want to set these values permanantly, and not have to perpetually reset the enviroment to run my apps, I should do this through the Advanced tab on the System Properties window?

Finally, a clarification. The exact names of the variables I need to set (on WinXP) are:

  the classpath (where jogl.jar goes):                                   CLASSPATH
  the library path (Where the unjarraed native .dll files go):     JAVA.LIBRARY.PATH 

I just need to make sure of that before I go poking around in my system’s innards… those “Informative Tutorials” on Google are never clear on this point.

  -THX, Dudes!!

P.S.: That hairbrained autoexec.bat idea seemed to be the only way to make windows remember those enviroment variables, otherwise they would reset everytime I closed the shell. If this System Properties window thing will make those variables stick in memory, I’ll owe you guys one. Write back!

Don’t set CLASSPATH at all if you can help it, and java.library.path (lowercase) is a Java System property, not an environment variable.

[quote] If I want to set these values permanantly, and not have to perpetually reset the enviroment to run my apps, I should do this through the Advanced tab on the System Properties window?

P.S.: That hairbrained autoexec.bat idea seemed to be the only way to make windows remember those enviroment variables, otherwise they would reset everytime I closed the shell. If this System Properties window thing will make those variables stick in memory, I’ll owe you guys one. Write back!
[/quote]
It will.

In general if you are using an IDE you will setup JOGL as a library in the IDE and nto have to worry about environment variables. When you deploy your application you can use Web Start and it will handle these details as well, or you can write a launcher stub (an .exe or a batch file, whatever) that will invoke the java.exe command with the -classpath and -Djava.library.path=whatever set.

You forgot the jogl natives.