a noob question about imports

Hello everyone;

I’m a Debian/Linux user with a moderate prior exposure to Java; much much earlier today I thought it would be fun to pick up the language again, and what better way to do that than to use a familiar library like opengl, right?

So, I installed java and the jogl stuff from apt (JSR-231, version 1.1.1-1).

These demos run fine on my system:
https://jogl-demos.dev.java.net/

But god forbid they share the source code! How completely worthless!

So, I’ve spent the last 3 hours trying to figure out how to import the bloody libs.

Here are some things I’ve tried:


import net.java.games.jogl.*;

This is met with “error: The import net cannot be resolved”.

Oh right. Fine, lets try this:


import javax.media.opengl.GL;

This is met with “error: The import javax.media cannot be resolved”.

and just for good measure (in the console)

locate jogl.jar

which returns: /usr/share/java/jogl.jar

Also, one of the stickies recommends this to verify that things should work:

System.loadLibrary("jogl");

Well, that one ran ok!

What am I doing wrong? This is driving me crazy!

Hi!

The JARs and the native libraries have to be in the PATH to allow the JVM to find them to use JOGL properly. I have used JOGL under Debian Linux and I’m currently under Mandriva Linux 2007, it works.

[quote]But god forbid they share the source code! How completely worthless!
[/quote]
From the page you linked:

[quote]The source code for these demonstrations is available via CVS.
[/quote]
The direct link: https://jogl-demos.dev.java.net/source/browse/jogl-demos/trunk/src/demos/
Hope that helps.

Alright, I got downloaded the demo’s from svn; I also updated my path variable to include the directory which jogl.jar resides.

Attempting to compile the “gears” demo results as so:
“The import javax.media cannot be resolved” etc.

So no dice still.

Random thought:
Do I have to pass some kind of command line switch to javac like I do for c/++ to inform it that I’m using an external library?

What am I doing wrong? This is driving me nuts.

‘javax.media’ is part of the JMF. Get the latest version from here.


export CLASSPATH=/usr/share/java/jogl.jar

Adding that to my .bash_rc fixed the problem with the import errors… (rather than appending to my PATH variable.)

But attempting to compile any of the demos results in a swath of other errors.

I give up >:(

Aw, don’t give up! Post up the first few lines of the first error you get…

I managed to compile the stuff using;
javac -cp lib/jogl.jar;lib/gluegen-rt.jar -d classes src/*.java

and run it with;
java -Djava.library.path=natives -cp lib/jogl.jar;lib/gluegen-rt.jar;classes; SimpleJOGL (or whatever class)

in other words you need to include the ‘lib’ folder with jogl & gluegen jars in the compile, and the ‘natives’ folder and the ‘lib’ folder in the run.

Well, it worked for me…

Ah, well… I tried out another java opengl library, and got it working. I just need an opengl interface to tinker with, I’m not too picky; this project is just so I can re-familiarize myself with java.

Sorry folks :frowning:

In the worst case, use the dirty way. Copy the JARs of JOGL (jogl.jar and gluegen-rt.jar) in jre/lib/ext and the .so files in jre/lib/i386. Then it will work.

Or just use Netbeans 6.5.1, the Netbeans OpenGL Pack and one of the provided template projects… and don’t copy anything to your jre unless you really know what you are doing (no offence Lunpa, but in respect to java, I think you aren’t there yet ;))

gouessej, even if it might work this way, please don’t advise this to someone new to java. Putting libraries into the endorsed folders can break everything from applets to a JOGL NetBeans Form designer project and in worst case crash the vm if you start mixing native lib versions.

classpath and library path, thats everything you need to start a jogl/lwjgl app from comandline.

There are already far to many threads out there describing exactly this issue.

You’re right; I am totally nowhere near “there” :smiley:

Using netbeans is probably the best solution to this; I started using the ide with lwjgl. (But ran into a rather stupid snag with lwjgl in regards to how they like textures)

Netbeans is pretty awesome. In general, I can’t stand java, but netbeans makes my grievances very transparent.

So f*** it. At some point in the future, I’m going to start my project over with netbeans and jogl, but for now I think I’ll keep this experience under my hat.

Thank you for your help :slight_smile: I’m very impressed with this forum of people so far.

It is better than giving up but you’re right, it causes some problems