Setting up Slick2D with Eclipse

From Slick2D Wiki
Jump to: navigation, search

Introduction

This tutorial will run you through the steps you'll need to set Slick2D up with Eclipse.

Since Slick2D uses LWJGL, setup is split into 2 parts, the JAR files, and the LWJGL natives (*.dll files for Windows, *.so files for Unix and Linux and *.dylib/*.jnilib for Mac).


Downloading and Extracting Slick2D and LWJGL

  • Extract the LWJGL zip (lwjgl-x.x.zip) file somewhere in your computer, remember or note down the location, you will need this later. We suggest you create a library (/lib) folder to store all these files in a well-known place.


Setting Up Slick2D and LWJGL in Eclipse

Extracted from LWJGL with Eclipse

  1. Open up Eclipse.
  2. Go to Project --> Properties in the menu bar.
  3. Click on Java Build Path.
  4. Click Add Library...
  5. Select User Library
  6. Click Next
  7. Click User Libraries
  8. In the user libraries dialog select New
  9. Type in Slick2D or any other name that you want for the Library Name, click ok
  10. Select the new library and
    1. click the Add Jar button (if the libraries were extracted to the project space)
    2. click the Add External Jar button (if the libraries were extracted to a location outside the project space)
  11. Go to where you extracted slick.zip and add the following '.jar' files ('Ctrl', or 'Shift' to select multiple entries) from 'lib' folder
    1. lwjgl.jar
    2. slick.jar
    3. jinput.jar
    4. lwjgl_util.jar (if want to use OpenGL's GLU class)

Setting Up a Project to use LWJGL in Eclipse (as of January 2015)

  • In a new Java project:
  1. Right-Click your project node and click Build Path > Configure Build Path or
  2. Go to Project > Properties and select Build Path, select the Libraries tab
  3. Click Add Library
  4. Select User Library, click next
  5. Add your Slick2D Library, created as instructed above
  6. Setup the Native Libraries path
    1. From the Properties Dialog on the Library tab expand the Slick2D Library
      1. Click the Natives Library Location and click the Edit button
      2. Navigate to the location of the LWJGL native folder and select the sub folder for the specific OS
      3. Click OK
    2. Alternatively before Running the project you have to add the following to the Run Configurations VM Arguments
      1. Select Run Configurtion
      2. Select the Project
      3. Select the Arguments tab
      4. On VM Options put the following:
   -Djava.library.path=<lwjgl-X.X path>/native/<linux|macosx|solaris|windows> 
   MORE SIMPLE:
   -Djava.library.path=<PATH WHERE YOU PUT SLICK>

Note: Remember to select the natives of your operating system.