If we want to use LWJGL and Slick2D in a Eclipse Project, we must perform a series of simple steps.
For starters, try to have the latest versions of both tools (LWJGL and Slick2D), which sometimes is not an easy task with Slick.
LWJGL can be found at: http://www.lwjgl.org/
Slick2D can be found at: http://slick.cokeandcode.com/
LWJGl and Slick brings a lot of jars witch a lot of functionalities, but we are going to need only the basic jars, they are:
LWJGL:
lwjgl.jar
Slick2D:
slick.jar
Download the tools everywhere you like (except maybe in the eclipse folder).
Note that slick.rar from http://slick.cokeandcode.com/ already have lwjgl and other things with in. we are going to use only slick things from there. So, still it’s recommended download them separately.
Now, to use LWJGL and Slick within a project in Eclipse, follow these steps carefully:
1 - Create a new Java Project.
2 - Create a folder in the project called “lib”. There will place the two jars above, but also we will place the .dll files required by LWJGL to work properly on each operating system.
LWJGL works on Linux, Mac, Solaris and Windows. But requires specific libraries for each one.
Such libraries (.dll files) are in the folder “lwjgl-2.8.4/native/OS_name”. Copy all the .dll of your operative system to “lib” folder of the project.
Just to know, the windows .dll are:
(slick.rar have the natives too, but try to use the ones who came on the LWJGL download)
jinput-dx8.dll
jinput-dx8_64.dll (64bits)
jinput-raw.dll
jinput-raw_64.dll (64bits)
lwjgl.dll
lwjgl64.dll (64bits)
OpenAL32.dll
OpenAL64.dll (64bits)
3- Back in eclipse, go to the “lib” folder and select the two jars (lwjgl.jar and slick.jar). We will proceed to link them to the project:
(if you cant see the new files, press F5 to reload the folder inside Eclipse tree)
right click on project Name-->BuildPath-->Add to BuildPath ...
Both jars are already linked to the project and can be used. Note that in the project tree we can see now a “Referenced Libraries”.
4- If at this time we tried to run code that makes use of one of the jars attached, we would get an error saying that LWJGL is not on the library.path or something like that. The problem is that LWJGL is not using the .dll files placed in “lib” folder because doesn’t know where they are. To indicate this:
right click on the project name–>properties–>Java Build Path–>Libraries–> select lwjgl.jar, drop down the small menu below him and we will see a line that says: "Native Library location: none ". We have to put the path to the “lib” folder of the project where de .dll files are. With this done, Slick2D and LWJGL are functional. But is recommended one more step to go.
5- It is essential, when developing applications, have the Slick javadoc associated to the project. The javadoc is what contains the information that you see in the contextual menus that show ups when you are coding.
The way to link the javadoc of slick to our project:
right click on the project name-->properties-->Java Build Path-->Libraries--> select slick.jar, drop down the small menu below him and we will see a line that says "Javadoc location: none". We must put the path to javadoc. It is on the same folder where you have downloaded Slick: "C:/your path of downloads/slick/javadoc/". (Click on "validate" to see if it is the correct path).
6- Done. Slick2D and LWJGL are fully functional in Eclipse.