Writing Java Games with Slick. Part One: Setting up an Eclipse Project

Posted: February 7, 2011 by jellymann in computers, firsts, java, programming, tutorials

This tutorial isn’t really aimed for anyone in particular, but I assume you already know the basics of object orientated programming. If you already use Eclipse for Java development and know your way around it then you can probably skip this one and wait for part two.

For part one you need to have Eclipse for Java developers (download) and the Slick graphics engine (download) that I will be teaching you how to use in the future.

This tutorial requires that you have at least Java 1.5 installed on your system.
To see if you have the correct version Java installed, open a Command Prompt or a Terminal window, type java --version and press enter. If your computer does not recognize the command, then you do not have Java installed. You can download Java here.

Note to Apple users: Mac OS X already has Java installed.

1. Creating a new project in Eclipse.

In Eclipse, click File > New > Java Project. A window like this should appear.

Enter a name (e.g. “Slick Tutorial” or “Clam Chowder Deluxe”). Then click Finish. You should now see your project in the list 🙂

Note: If you do not see a ‘src’ folder, you will have to add it: Right-click on your project, go to Build Path > New Source Folder… type in ‘src’ and click Finish.

2. Adding Slick to your Build Path

Right click on your project and select Build Path > Add Libraries. You should see this:
Select User Library and click Next


Click User Libraries…


Click New… and type in “Slick” and click ok. Now you will have a new entry in the list of User Libraries.


Click on the newly created Slick, click Add JARs… then navigate to where you extracted Slick, go into the ‘lib‘ directory and select lwjgl.jar and slick.jar then click ok.

You should see the jars added to the list:

Now double-click on Native library location under lwjgl.jar, click External Folder… and select the directory you extracted slick (the root, not ‘lib’) and click ok.

Note: By default the root of the Slick folder only contains Windows 32 and 64-bit dll’s. For other systems, look in Slick/lib and find a native jar that matches your system. Extract them into a folder and select that as your native library location.

Next double-click on Javadoc location under slick.jar, click Browse…, navigate to your Slick folder and select javadoc and click ok. Click validate, it should say the location is likely valid. If all is well click ok to go back to the User Libraries window.

Things should look similar to this:

Now click ok, and then make sure “Slick” is checked.

Click Finish. You should now see Slick in your project, like this:

All done !

In the next installment we’ll get started with the code 🙂

Advertisements
Comments
  1. Yatekii says:

    Awesome! Thx very much, u helped me get this runnin on my Mac 🙂

  2. Thank you so much for such as use full tutorial for a beginner like me. Nothing to say, just awesome!

  3. Mikkel says:

    When I try to run I get a lot go errors. It’s says no source attachment to the slick jar files.
    Any ideas what I done wrong?

    • Mikkel says:

      Hi, agin
      I solved my problem, actually with you tutorial. It was because I run windows 7 86 bit.
      I happen to find your guide (Slick java library and 64 bit) in Google. you should maybe link to it in this tutorial.
      But good work by the way, this is the best tutorial I’ve seen.. maby ever 
      THX!

  4. philba says:

    Thanks a lot for that pretty well explained setup!

  5. Richard Kling says:

    Got everything entered… twice, and checked twice. Press ctrl-F11 to run and get all of this:
    Exception in thread “main” java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at org.lwjgl.Sys$1.run(Sys.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.lwjgl.Sys.doLoadLibrary(Sys.java:68)
    at org.lwjgl.Sys.loadLibrary(Sys.java:84)
    at org.lwjgl.Sys.(Sys.java:101)
    at org.lwjgl.opengl.Display.(Display.java:128)
    at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.newdawn.slick.AppGameContainer.(AppGameContainer.java:36)
    at slick.tutorial.TutorialGame.main(TutorialGame.java:42)

    What am I doing wrong?

    • jellymann says:

      Check your project’s build path. The Slick library needs to know where the native libraries are stored. You may have selected the wrong folder.

  6. Akka69 says:

    Hi, does anyone know why the Slick2D download link is not currently answering?

  7. Thanks a lot for this post, I was struggling to setup Slick on Eclipse.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s