Extreme newbie alert: using lwjgl with Eclipse

Started by teamonkey, September 12, 2003, 20:46:02

Previous topic - Next topic

teamonkey

Hello. I'd like to introduce myself. I'm teamonkey from yakyak.org.

I'm pretty new to the whole Java thing, and I've only just got my hands on Eclipse and lwjgl. Can someone please tell me how to link lwjgl into my Java projects? I get a
java.lang.UnsatisfiedLinkError: no lwjgl in java.source.path
...


Can anyone help? I know it's a pretty fundamental thing...

Cheers :D
teamonkey]

princec

Hi teamonkey! Welcome to a slightly less fluffy forum!

It's dead easy: Java needs to know where to pick up DLLs from, every time it's executed. There are several ways but the most sensible way is to use an argument when invoking programs:

java -Djava.library.path=<path to your lwjgl.dll> -cp etc etc etc

In Eclipse, that's in the Run... menu, Program Arguments tab. Just add a -Djava.library.path=<wherever> and you're laughing.

Cas :)

teamonkey

Thanks princec!

It took me far too long to realise that it was a .dll problem :oops:

I fixed the problem by putting the .dlls in the Windows/System32 directory, but thanks for telling me how to do it properly.
teamonkey]

PlanetMongo

Hrm..

Okay, I'm trying to get lwjgl up and running with eclipse (have been using textpad) and am experiencing some difficulty...
I've added c:\lwjgl\lwjgl-0.8-win32\ to my CLASSPATH variable..
I've copied all the .dll's and .jar's to c:\windows\system32 and c:\j2sdk1.4.2\bin and \lib
(in attempts to resolve this)
I've also gone into Run->Arguments and added
-Djava.library.path=c:\lwjgl\lwjgl-0.8-win32\


Now, in Eclipse, I'm trying to do this:
import org.lwjgl.*;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*;


Each one of those lines has a big exclamation point beside them, each saying "the import org.whatever cannot be resolved", which of course makes this a bit difficult.  I'm actually trying to run Nehe01, where it also bombs out on the package name Nehe01.  But that's besides the point, if I comment out the package part, it still doesn't do anything for the rest of the code...

Any ideas?

:: feeling stupid ::

EDIT:
Compiling Nehe01.java in TextPad generates no errors, but trying to run it gets a :
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/opengl/Window
               at Nehe01.Nehe01.<clinit><Nehe01.java:28>

error...
ife sucks, kill yourself.

princec

In your Eclipse project you should click on Properties and get the Java Build Path up. Go to the Libraries tab and click on Add External Jar. Point it at the lwjgl jar. There you go. You shouldn't need to fiddle around with CLASSPATH.


Cas :)

AndersD

...and remove the dll and jar files you recently added to system32, java\bin,java\lib
as having them there is a great way of introducing confusing errors if [when] you update your version of lwjgl :)

PlanetMongo

Ahh.. that got it.  Thanks..

Now two other questions based on Nehe01:
the line
GLCaps.determineAvailableExtensions();

is "invalid"?  Perusing the method list, determineAvailableExtensions now requires a Hashset...
two lines down from that is:
GL.wglSwapIntervalEXT(1);


That method no longer appears to be valid, either...

Thanks in advance..

EDIT:  Commenting out that bracket of code results in clean compilation and running (i.e., I get a window)..
ife sucks, kill yourself.

PlanetMongo

Another question:  could someone explain how the package keyword works?  Why does eclipse barf with package Nehe0x;, but commenting it out works fine and runs fine?
ife sucks, kill yourself.

Matzon

All source files, have to be placed in same directory structure. That is, if you declare a file /src/MyFile.java to be in:
package nehe;

then you have to place it in the folder:
/ser/nehe/MyFile.java

princec

You no longer need to call determineAvailableExtensions any more, it's done for you. And wglSwapIntervalEXT has been replaced by the cross-platform command:

Window.setVSyncEnabled(true)

and corresponding

Window.isVSyncEnabled()

Cas :)

PlanetMongo

Thanks again for the answers.. Hopefully I'll be done asking these questions so I can promptly forget the answers and have to reask them in 6 months.. ;)

1)  Regarding VSync:  I thought Windows didn't do this?  I know when I was playing with the code I did a isVSyncEnabled and got "false", but I seem to recall Windows doesn't do VSync enabled (but Linux does?).  Does LWJGL automatically "fallback" to non-VSync if you try to set it?  (sounds like an opportunity for me to just try it.. Hrm..).. Okay, after setting VSync to true, I do indeed get the value of true back from lwjgl under WindowsXP...

2)  This is more Nehe specific, but I was hoping someone might point me in the "right" direction as to how to fix:
In the various Nehe's, they like to make a little GL window and render in it.  I noticed that on my home system, which uses a dual monitor setup, it "squashes" the objects horizontally in this windowed mode.  Now, I usually change that to full-screen after I initially run, and then it looks normal, except that now it renders across the two monitors.  :P  I know AlienFlux does not do this based on the demo I've run, so I assume it's just a "bug" in the tutorial.  I'm thinking I should be looking at gluPerspective?  (aspect-ratio?)

3)  The little maze running demo in Nehe is bizarre.  At least in my runs it is.. You tend to run.. sorta at an angle and the angles look wrong.  Like trying to run through a fun house.  It actually made my stomach turn trying to run through it.  It reminds me of my old Doom II days (the last FPS I've ever played), but Doom II didn't have this perspective warping...

Thanks again!
ife sucks, kill yourself.

PlanetMongo

Yet another stupid question regarding the above:

Where is the appropriate place to set Window.setVSyncEnabled(true)?

Currently, I'm doing that right after Window.create(...).
ife sucks, kill yourself.

whatever23

i am using eclipse 2.1.2 and am trying to get it to run lwjgl
i get the following error:

java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

i have added the argument to the run...->arugments
and have added the jar to the project yet i still have this problem. i know this has to be something really simple, i just can't figure it out  :cry:
ever underestimate the power of human stupidity.

princec

Yeah, it is :)
It's now looking for the .DLLs, and you have to tell Java where to find them, too, using
-Djava.library.path=<path to dlls>

Example:
java -Djava.library.path=c:\lwjgl-0.8 -cp c:\lwjgl-0.8\lwjgl.jar;MyGame.jar mygame.Game


Cas :)

Hungry Joe

heres a non lwjgl question but it is about eclipse...

if im trying to import org.lqjgl.vector.* in eclipse, i type org.v and the little autocomplete box opens up to 'org.lwjgl' . i can now press enter in which case it will import org.lwjgl.* and i find i have to delete .* and type the . again if i want autocomplete to pop up the .vector and give me org.lwjgl.vector.* anyone know what you are meant to do to go further down packages using autocomplete

sorry i would ask this in an eclipse forum but i havent.