Newbie Help

Hi,

I am getting back into Java programming (I used to do it obsessively about 7 years ago) and I am having terrible difficulties with importing certain packages. I am specifically interested in using Jogl and my problems have started since I tried using it, but they might be caused by something unrelated to Jogl. From what I can tell the problem is a minor one, so I am hoping that someone will know what I have done wrong.

From the beginning.
I downloaded the latest JDK, JRE, NetBeans, and then I got the latest Jogl build. I added the paths to the PATH and CLASSPATH variables – like every article on the topic instructs. Then I downloaded a number of extremely simple Jogl tutorials as well as Chris Campbell’s PhotoCube demo – as a NetBeans project.
The problem has been that the imports aren’t registering, they aren’t being found.

For example, Cambell’s PhotoCube uses these (among others) and they aren’t found:

import org.jdesktop.animation.timing.Cycle;
import org.jdesktop.animation.timing.Envelope;
import org.jdesktop.animation.timing.TimingController;
import org.jdesktop.animation.timing.TimingEvent;
import org.jdesktop.animation.timing.TimingListener;
import org.jdesktop.animation.timing.interpolation.ObjectModifier;
import org.jdesktop.animation.timing.interpolation.PropertyRange;

Originally, an even greater number of imports didn’t work but I fished around the internet until I found some packages that seemed to be what I needed, downloaded them into a “Packages” folder, and added the folder to my project libraries.

It would seem, from the failed imports listed above, that I need the org.jdesktop.animation.timing package . . . but I have it, that is why these DO register:

import org.jdesktop.animation.timing.TimingTarget;
import org.jdesktop.animation.timing.interpolation.KeyFrames;
import org.jdesktop.animation.timing.interpolation.KeyTimes;
import org.jdesktop.animation.timing.interpolation.KeyValues;
import org.jdesktop.animation.timing.interpolation.ObjectModifier;

I can’t understand this. Why would some be found and others not?

In regard to Jogl, most of the demos I have downloaded use net.java.games.jogl.* (which didn’t register) while Cambell’s PhotoCube used javax.media.opengl.GL; (which I eventually got to register somehow). Are these two different versions of the same thing? Different packages?

From what I have read, everyone seems to think that if I just download the jogl stuff and add it to my PATHs and/or project libraries list, everything will be found. That isn’t happening. Any suggestions?

[I am assuming that I am simply missing some crucial packages or haven’t put something in the right place.]

Don’t know about your other problems, but the jogl package prefix has changed, since it is the “official” java opengl binding. “javax.media.opengl” is the new and now correct package prefix. I suggest not to add the jogl libraries to your path and expecially not putting jogl in JRE/lib/ext. Just download the distribution for your platform from: https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=6901&expandFolder=6901&folderID=6750

Extract the archive to a folder, add the jogl.jar and gluegen-rt.jar to your libraries in netbeans and specify -Djava.library.path= as vm arguments in your projects properties panel under the run node.

Ok. I was having all sorts of problems with my jdk/jre/netbeans so I got rid of everything and reinstalled it all. All of the relevant directories now look like this:

d:\Program Files\Java
docs
jdk1.6.0
jre1.6.0
Packages
jogl-1.1.0-pre-20070310-windows-i586
Projects
App\

The App netbeans project is a very short and simple jogl program (it is merely a NetBeans project version of the PrintExt.java demo). I added my jogl.jar and glugen-rt.jar files (from the jogl directory listed above) to my project’s library list and it compiled fine – all of the imports were now found. But when I tried to run it I got these errors:

Exception in thread “main” java.lang.UnsatisfiedLinkError: no jogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:78)
at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:101)
at com.sun.opengl.impl.NativeLibLoader.access$100(NativeLibLoader.java:47)
at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLibLoader.java:109)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.opengl.impl.NativeLibLoader.loadCore(NativeLibLoader.java:107)
at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.(WindowsGLDrawableFactory.java:60)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
at javax.media.opengl.GLCanvas.(GLCanvas.java:113)
at javax.media.opengl.GLCanvas.(GLCanvas.java:82)
at javax.media.opengl.GLCanvas.(GLCanvas.java:75)
at app.Main.main(Main.java:34)
Java Result: 1

I know that you suggested to add “Djava.library.path=D:\Program Files\Java\Packages\jogl-1.1.0-pre-20070310-windows-i586\lib” to my VM Run parameters, but that didn’t resolve this issue.

Is my compiled program just not finding the jogl jars/dlls? How do I get it to find them, or make them part of the project (i.e., internal)?

Thanks.

That’s exactly the problem.

the commandline arguments are picky about spaces in them and if that’s no type, you have forgotten the “-” before the option. Try:


-Djava.library.path="D:/Program Files/Java/Packages/jogl-1.1.0-pre-20070310-windows-i586/lib"

The forward slashes are not exactly necessary, but I formed a habbit of using them, since they work equally on all platforms.

Thanks, that worked!

One quick question. How will it run outside of NetBeans? If the required jars are ‘pointed to’ through NetBeans’ Run parameters, how does one give the finished product to someone else, who uses different folders and isn’t running it from NetBeans?

I’m not at that stage, but I am curious as to how it will have to be done.

I think netbeans just copies the jars to the dist-folder, if you select “build project” from the right-click menu of the projects main-node. That does not copy the natives afaik, so you have to copy them manually. Additionally you have to create a litte shell/batch script to start the app by “java -Djava.library.path=. -jar YourMainJar.jar”. The latter does only work, if you have the natives in the same folder as your main jar.