I\'m trying to start my java game but I have some troubles with the java command line:
Here is what I type:
C:\\>java -Djava.library.path=%cd%\\lib
You use the java.library.path
option to specify the location of native libraries to load. In the location pointed to by that option you would place all dll
or .so
files required by LWJGL. On the other hand, you need to make sure that all required JAR files are on your classpath, via the -classpath
option. Currently, you have your JAR files in the wrong directory.
In Eclipse, if you using maven.
Add the following to the project "Run" : "VM options" .
-Djava.library.path=yourpath/youproject/java/target/natives
This because lwjgl library is made by two components:
The first error you are getting is because you are setting the library path, that should contain the native library, but it does contain the .jar. So you get a java.lang.NoClassDefFoundError
because you should set either the library path to the folder that contains native library, either the classpath to contain the real lwjgl.jar file.
The second error that you get with Eclipse is a successive step: your classpath contains the jar library but it is not able to find the native library attached to it, you can fix it in the following way:
You should specify explicitly which lib files to include (seperated by ;) :
-cp %cd%\lib\lwjdl.jar;%cd%\lib\<another-lib>.jar
Don't be tempted to use the wildcard * as it will cause more harm than good (from previous experience :))