The Coder's Handbook
Setting Up Eclipse and Slick 2D
DOWNLOADING AND RUNNING
Downloading the File
Click on the button below to download Eclipse Portable from Google Drive
This is a portable application: it will run on any computer without installation. It includes three elements:
Eclipse - Your integrated development environment (IDE). This is an editor, compiler, and debugger.
Java Development Kit - The language itself which allows your program to run
Slick 2D - A game development library built with the Lightweight Java Games Library (LWJGL) and Open GL.
Unzipping the File
Right click on the zipped folder and choose Extract All.
On the next screen, choose Extract.
You should now have an unzipped folder in the same directory.
This step may take a little while (~5 minutes on lab PCs)
Once complete, delete the original zipped folder
Move To Flash Drive
Create a folder on your flash drive called Computer Science
Copy the unzipped Eclipse Portable folder to your Computer Science folder.
Running
When you first run the program on a school computer, you may get a blue warning screen from Windows
In the top left click More Info and a new option at the bottom will appear.
Choose Run Anyway.
SETTING UP PROJECTS
Finding the Projects
Your version of Eclipse comes preloaded with three example projects from Mr. M
Unfortunately, the processing of zipping the file causes Eclipse not to be able to find them
To update Eclipse on their locations, you'll need to:
Select File --> Open Projects on File System
For import source, choose Directory
Navigate to your Eclipse Folder, then to go Data and select Workspace
Your screen should look similar to the one on the right.
Hello World
First, let's open up the project HelloWorld
In the package explorer on the left you'll select the Project, then open up src (your source code) and default package.
Click on Hello.java. The code will display on the right.
Running a Project
When you want to run a project, make sure you have one of the following selected in the package explorer. This allows Eclipse to find which main you want to run.
The class that contains your main method
The top level of the project
Press the Green "Run" Button
If this runs the wrong project, click the down arrow to the right of it and select "Run as Java Application" and choose the file you want to run from a list
Eclipse doesn't care what tab you have open on the right, only what is selected in the package explorer.
SlickExample
This project is an example of how you can use graphics in Slick2D. Just consider it sample code - it's not tied to any specific project.
Open it up and poke around. When you're ready, try running it as you did with Hello.
To exit out of a full screen slick project, you will need to press ALT-F4.
If you see the screen on the right when loading it up, don't panic!
This is just Eclipse asking you which Slick2D thing to run. Look for the one called Main and select it. If it's not at the top, they're in alphabetical order.
You should see a bunch of shapes and some interaction with key presses.
ProjectTemplate and Making New Projects
For your convenience, Mr. M has made a blank project template. You want to be careful not to overwrite it.
When making a new project, you'll want to COPY the template and PASTE it in the package explorer
Just click on the project and press CTRL-C then CTRL-V.
Give your new project an appropriate name
Renaming Projects and Linking Errors
Due to the way the Slick2D libraries are set up, you need to be careful and avoid renaming your project using the Refactor menu option.
Instead, when you want to rename a project simply copy it, paste it, give it a new name, and delete the old one.
This is very silly, but saves you an annoying step.
SETTING UP YOUR WORKSPACE
Preferences
Go to Window --> Preferences to change Settings. In general, it's easy to just search for things you want to change, such as:
Font - You can customize your font and size. Your code is listed as "Text Font."
Theme - Under appearance you can change to other modes, like Lightmode.
Window Positions
Feel free to move aroundthe console, outline, or package explorer.
If you lose a window and want to brings things back to normal go to Window --> Perspective --> Reset Perspective
TROUBLESHOOTING
Linking Error and Native Files
Every Slick project comes with a files that connect the library to your native operating system.
When you rename your project, sometimes these links might get broken. To fix them...
Opening the Build Path
Right click on your project in the Package Explorer
Select Build Path ---> Configure Build Path (see fig. 1)
In the Java Build Path
Expand JRE System Library
Click on Native Library Location and choose Edit (see fig. 2)
Select Workspace and navigate to libs --> natives. (see fig. 3)
Hit Okay, then Apply and Close