Can't run NEHEs samples.

Started by redneon, June 02, 2005, 10:46:55

Previous topic - Next topic

redneon

I'm trying to familiarise myself with the compilation and running of lwjgl before I start programming it. I downloaded NEHEs Lesson 2 and extracted the .jar. I entered the directory and compiled it like this...

javac -cp lwjgl.jar Lesson02.java

Which compiled fine. Obviously I copied lwjgl.jar into the same directory. When I go to run the example like this...

java -cp lwjgl.jar Lesson02

...however I get an error saying...

Exception in thread "main" java.lang.NoClassDefFoundError: Lesson02

I've also tried "java -Djava.library.path=native -cp lwjgl.jar Lesson2" but I get the same problem.

Any ideas?

kevglass

You need to include the current directory in your class path since thats where Lesson02.class is.

java -cp .;lwjgl.jar Lesson02

(use a : instead if you're on Unix).

Kev

redneon

Quote from: "kevglass"You need to include the current directory in your class path since thats where Lesson02.class is.

java -cp .;lwjgl.jar Lesson02

When I do "java -cp .;lwjgl.jar Lesson02" I get a different error...

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.libr
ary.path
       at java.lang.ClassLoader.loadLibrary(Unknown Source)
       at java.lang.Runtime.loadLibrary0(Unknown Source)
       at java.lang.System.loadLibrary(Unknown Source)
       at org.lwjgl.Sys.<clinit>(Sys.java:61)
       at org.lwjgl.opengl.Display.<clinit>(Display.java:96)
       at Lesson02.createWindow(Lesson02.java:127)
       at Lesson02.init(Lesson02.java:147)
       at Lesson02.run(Lesson02.java:56)
       at Lesson02.main(Lesson02.java:47)

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.libr
ary.path
       at java.lang.ClassLoader.loadLibrary(Unknown Source)
       at java.lang.Runtime.loadLibrary0(Unknown Source)
       at java.lang.System.loadLibrary(Unknown Source)
       at org.lwjgl.Sys.<clinit>(Sys.java:61)
       at org.lwjgl.opengl.Display.<clinit>(Display.java:96)
       at Lesson02.createWindow(Lesson02.java:127)
       at Lesson02.init(Lesson02.java:147)
       at Lesson02.run(Lesson02.java:56)
       at Lesson02.main(Lesson02.java:47)

Any ideas?

kevglass

Thats because you haven't got the native library somewhere that java can find it. You need the .dll or .so (on linux) either:

- In the local directory

or

- Specified in the system property java.library.path, i.e.
    java -Djava.libarary.path=<location of naive libs> -cp .;lwjgl.jar Lesson02

Kev

redneon

Thanks that's worked. One question though. Why do I still need the .jar file when I have the .dll? Surely the .dll should encompas everything?

kevglass

Nope, in the land of java we have native stuff to bind to specific system dependent things and pretty java stuff that's platform agnostic. The dll just contains the native stuff.

Kev