Posts tagged: eclipse

Slick, Phys2D, LWJGL, and Eclipse

This guide will be as straight-to-the-point as can be. Please note, I make an example of the Linux version in this setup, but you can substitute the instructions for Windows or Mac if that is what you use.


Create an Eclipse project that uses Slick, Phys2D and LWJGL.


  1. Slick – website – Download the “full distribution” (~ 9.8 MB)
  2. LWJGL – website – I prefer to use the “last stable build” from the project repository (currently 2.2.0, ~ 3.6 MB)
  3. Phys2D – website – Download the latest build (current build 2008-04-06, ~ 100 KB)


This is a personal preference, but I rename the Phys2D download. It downloads as phys2d-060408.jar, so I rename it phys2d.jar.

Next, extract/unzip the file, it doesn’t matter where. We will import the files into the Eclipse workspace later anyway.

Open up Eclipse and start a new project.

File >> New >> Java Project

Presumably, you know your way around Eclipse so I will not help with the specifics of creating a project.

Now that the project is created, create a new folder called lib in the project.

File >> New >> Folder
Click the project name
Folder name: lib

Next, we import Slick and Phys2D into the project.

Right click lib >> Left click Import >> General >> File System >> Next
Browse to the unzipped slick directory and find the slick/lib folder >> OK
Select the following jar files
  • jogg-0.0.7.jar
  • jorbis-0.0.15.jar
  • lwjgl.jar
  • slick.jar
Click Finish

You’ve imported Slick, now we import Phys2D.

Right click lib >> Import >> General >> File System >> Next
Browse to the location you put phys2d.jar >> OK
Select phys2d.jar >> Finish

Now your lib folder should have those five jar files in them. Just about done.

We need to add the jar files into the project build path.

Right click the Project >> Properties
On the left, make sure Java Build Path is selected.
Click the Libraries tab >> Add JARs
Expand the Project
Expand lib
Select all of the jar files in the lib directory >> OK >> OK

You should now see a new directory in the Package Explorer called Referenced Libraries. The project is incomplete without first attaching the native libraries to lwjgl.jar. To do that, we first import those native libraries into the project.

Right click lib >> Import >> General >> Archive File
Browse to the unzipped slick directory and
select slick/lib/natives-linux.jar >> OK >> Finish
Do the same for natives-win32.jar and natives-mac.jar
(if you wish to support those operating systems)

Next, we attach those native libraries to the lwjgl.jar file.

Expand Referenced Libraries
Right click lwjgl.jar >> Properties
Select Native Library at the left of that window
Location path: >> Workspace
Expand the Project
Select lib >> OK >> Apply >> OK

Now you are ready to build your awesome game.

But wait, what about using the latest version of lwjgl? We skipped that step.

Right. We did. As of right now, we’re using the the version of LWJGL that came packaged with Slick. However, some users might run into a problem with LWJGL, particularly if you’re using Ubuntu 9.04 (like I am). At this point, if I were to try to compile a Slick program, I would end up with this error:

Failed to initialise the LWJGL display

The solution to which is to use the latest LWJGL native Linux libraries.

Extract that last stable build of LWJGL that you downloaded (
In Eclipse, Right click lib >> Import >> File System >> Next
Browse to the unzipped lwjgl-2.2.0 directory, to lwjgl-2.2.0/native/linux >> OK
Select all of the .so files (all of the files in the directory) >> Finish
Yes To All when asked to overwrite files

Not entirely done yet. Trying to compile now would result in the following error:

Version mismatch: jar version is '16', native libary version is '17'

So we replace the old lwjgl.jar with the new. Find it at lwjgl-2.2.0/jar/lwjgl.jar. Import it into the lib folder of the project. You know how to do that by now. Compile and run again and all should be well.

P.S. You are done with all the extra unzipped directories and zip files, etc. Everything needed to run your project has been imported into Eclipse. They can be deleted if you so choose.

Update: It seems that now there is an additional problem, as follows.

java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

The solution was found at the jMonkeyEngine forums. You need to tell the lwjgl.jar where it can find the native libraries so it can run. Basically it calls for

Right click the project >> Properties >> Java Build Path >> Libraries
Expand lwjgl.jar
Select Native Library >> Edit
Click Workspace
Expand the project
Click lib >> OK >> OK

Slick, LWJGL and Ubuntu 9.04

It has been a busy month for me and a slow month in regard to posting any sort of update here. I’ve been reading a whole whack of stuff. A giant whack.

Speaking of reading stuff, why not check out for some excellent reading material. Follow the author on Twitter, while you’re at it. I’m not being paid to promote 1889 books, it is just good stuff.

Back to the topic at hand, I want to share a tidbit of information. If you’re like me, you use Ubuntu. And recently, a new version of Ubuntu became available. So if you’re like me, you upgraded to Ubuntu 9.04 from Ubuntu 8.10. Then stuff broke. Because, like me, you use an ATI video card and ATI decided to not update last year’s model of video cards to work with the new version of X (the window system) in Ubuntu 9.04.

That’s a side rant, and possibly unrelated. My main problem was that the game(s) I’ve been writing would no longer compile, or run, with Ubuntu 9.04. Wait, it was Ubuntu’s fault? No. Something broke somewhere along the way and LWJGL was b0rken just a little bit (b0rken… look it up).

I fixed it. And you can, too. Grab the nightly build and replace your native libraries.

Now Slick (which uses LWJGL) and Eclipse and Ubuntu 9.04 all play nice together. Development of Generic 2D Platformer (and Pixahl) commence.

Right, I may be called on the name change to Piksahl. Piksahl was the Perl version, but that was just silly. Who programs a game in Perl? I started to, because I could. Now I’m doing it in Slick/Java. That makes more sense. Thus, the name change.

Staypressed theme by Themocracy