compiled source on two different IDEs and it won't run!!

Started by Jimmy_Scythe, May 25, 2005, 16:31:11

Previous topic - Next topic

Jimmy_Scythe

So I cut and pasted the LWJGL conversion of NeHe's Lesson01 tutorial from Wiki, cleaned up all the syntax errors, and got the code to compile with no problems on Netbeans 4.0, but I couldn't get it to run. Netbeans kept telling me that it couldn't find the LWJGL library in the class path so I made a new library and added it to the classpath under properties->Running Project->Add Library but it still couldn't find the library. Frustrated, I changed over to JCreator and followed the directions in the install section of the LWJGL website (the Netbeans instructions were for an earlier version) and encountered the same problem. The code compiles just fine but I can't execute it from the IDE even after I create an LWJGL library with the appropriate .jar files and add it to the class path. What am I doing wrong?

Matzon

what is the error exactly ?
unable to locate lwjgl.jar - or issues with lwjgl.dll ?
if the latter, supply path using -Djava.library.path=<path\to\dll>

Jimmy_Scythe

the error reads:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
               

it then proceeds to list various places that the code throws that exception. This error comes from the JCreator build but the exact same error is thrown from Netbeans 4.0. I've added the library to the build and even tried to place the *.dll files in the same directory as the Lesson01.class but nothing seems to work. I haven't tried the command line option that you specified but I'll get back to you as soon as I do.

Matzon

that error is caused by it not being able to locate lwjgl.dll

Jimmy_Scythe

Okay, copying the lwjgl.dll to the same folder as the Lesson01.class worked just fine with JCreator but not with Netbeans. Creating a folder for the *.jar and *.dll files and the specifying their path on a command line did work with both builds, I just can't execute the project from within Netbeans. Either way, I'm in business. Thanx for the help  :D

aldacron

Quote from: "Jimmy_Scythe"Okay, copying the lwjgl.dll to the same folder as the Lesson01.class worked just fine with JCreator but not with Netbeans.

Netbeans, by default, sets the working directory to the project's root directory. So if your project is in C:\MyProject (i.e. source is in MyProject\src, jar is in MyProject\dist, etc...), the C:\MyProject is the working directory. If you drop the dll in the project's root directory, it will run as expected.

Also, you can change the working directory. In Netbeans 4.1rc1 (no clue as to 4.0, but if not the same just dig around until you find it) you can do so by right-clicking on the project name in the project view and selecting 'properties'. In the 'Categories' box of the properties dialog, select 'Run'. Several textboxes will display on the right side of the dialog, one of which is named 'Working Directory'. It will be empty. Use the browse button to change the working directory to whatever you want.

I wouldn't change the working directory just to get the dll picked up though. Nor would I copy the dll to the project directory. See below.

QuoteCreating a folder for the *.jar and *.dll files and the specifying their path on a command line did work with both builds, I just can't execute the project from within Netbeans.

Yes you can. Do you really think the designers of an IDE like Netbeans won't allow you to specify command line parameters to the VM ;)? In Netbeans 4.1rc1, in the same 'Run' category of the project properties dialog, there is also a text box called 'VM Options'. Put your -Djava.library.path there and you should be golden. You can even pass command line args to the app via the box named 'Arguments'.

What I suggest you do is set aside a third party library directory somewhere. Mine is C:\dev. I have a subdirectory for each of the languages I work with (C:\dev\java, dev\c, dec\c++, dev\d). I dump all Java packages I might use into C:\dev\java (so I have C:\dev\java\lwjgl-win32-0.95, C:\dev\java\lwjgl-win32-0.96, and so on). I copy the latest version of the native dlls I want to use into C:\dev\java\natives, then each time I start a new project in an IDE (Eclipse, or more often these days, Netbeans) I configure the VM options with -Djava.library.path=C:\dev\java\natives. That never changes.

The reason for doing this is so that when a new version of a library is released, you can drop the dlls into the natives directory and every project on your system that uses that library will now use the new version. You don't have to copy it into each project tree. You can do the same with the jar files (in a 'jars' directory, or whatever).