
Slick2D engine is a high performance 2d game library based on a LWJGL(Lightweight Java Game Library). You can see the current features of Slick2D in their site. Download the library from here.
You can check the games made in Slick2D engine http://www.cokeandcode.com/ and http://slick.cokeandcode.com/gallery.php.
Tutorials : There are good and easy to go tutorials for beginners.
Now download the library. So here i’ll be telling how to setup the library with netbeans 6.5.1 so that u can write compile and run slick games easily and fast. I am using Ubuntu 8.04(Hardy heron), steps are similar for setting up in windows.
STEP 1: Download the library and save it in some appropriate place.
STEP 2: Open your Netbeans 6.5.1.
STEP 3: Go to tool->libraries. Library Manager window will open. Click New Library. Give it a name Slick. Then click OK.

STEP 4: Now click classpath tab. Click Add Jar/Folder. Browse the folder where u have saved Your slick library. Go to lib folder and add all the jar files except slick.jar. Click OK

STEP 5: Click JavaDoc tab. Click add/zip floder. Browse ur slick folder and select javadoc folder and add it. So done. Click OK.

STEP 6: Ok so your slick library has been created. Now few steps remaining to complete the full set up. Create a new java project called SlickTest. Now Right Click SlickTest project, then click properties. Project properties window will open up. At left side, under categories select Libraries. Now at right side click Compile tab. Now Click Add Jar/Folder. Browse ur slick folder, go to lib folder, select slick.jar and add it.

STEP 7: Now click Run tab. Click Add Library. Add Library window will open up. From there select Slick library that we previously created. Then add it.

FINAL STEP 8 : Now at left side select Run. At Right side, go to VM Options, there u have to provide the parameter/argument that will link lwjgl libraries to your application. So at VM Options textbox, For Ubuntu users write: -Djava.library.path=lwjgl library path For Windows user write: -Djava.library.path=”lwjgl library path”. And Click Ok
Thats it Windows users have to put the path within double quotes. Here lwjgl library path is the path to the location where .so files for ubuntu linux(liblwjgl.so, liblwjgl64.so, libodejava.so,libopenal.so etc) and .dll for windows(liblwjgl.dll, liblwjgl64.dll, libodejava.dll,libopenal.dll etc) are located.
For windows user .dll files comes with slick library but linux users have to download the native .so lib files.
So now you are done and lets write a simple program for testing. This code will just create a window. Create a class called Test under the project that we had created.
package com.padam.testing;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
/**
*
* @author padam
*/
public class Test extends BasicGame{
public Test(String name){
super(name);
}
public static void main(String[] args){
try {
AppGameContainer container = new AppGameContainer(new Test(“Game”));
container.setDisplayMode(800,600,false);
container.start();
} catch (SlickException e) {
e.printStackTrace();
}
}
@Override
public void init(GameContainer gc) throws SlickException {
}
@Override
public void update(GameContainer gc, int delta) throws SlickException {
}
public void render(GameContainer gc, Graphics g) throws SlickException {
}
}
NOTE: Linux and Mac users must download the lwjgl library. Then browse the folder and go to native folder. There choose your native OS folder. That will be your lwjgl library path thatt will go to VM Options parameter as specified on last step or you can copy the .so/native files to your convenient location and provide that path to VM Options parameter.
Now after this just test the above code. You may get a runtime error saying:
Exception in thread “main” java.lang.LinkageError: Version mismatch: jar version is ‘16′, native libary version is ‘17′
at org.lwjgl.Sys.(Sys.java:105)
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 com.padam.testing.Test.main(Test.java:26)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Linux/Mac/Solaris might face this problem because lwjgl jar files that comes with slick might be of older version which won’t match with the new lwjgl native .so/native files that u have downloaded. This means that the lwjgl jar files and lwjgl native/ .so files doesn’t match. So what u have to do is browse lwjgl folder that u have downloaded and go to jar folder and copy all the jar files and paste/replace the old jar files in the lib folder located in slick folder or location of slick library.
So Thats it. If u face any problem, comment it.
Gracias.








How to make a exe file of Java Program ?
If you are making a java program for windows operating system only then wouldn’t it be easy to have a exe file for your java program and distribute it to the users and user would find easy to execute your program. Well i guess yes because exe would definetly make easy for users to execute your java programs. So:
Q. How to make an exe file for your java program ?
A. exe4J.
exe4j is a Java exe maker that helps you integrate your Java applications into the Windows operating environment, whether they are service, GUI or command line applications. If you want your own process name instead of java.exe in the task manager and a user friendly task-bar grouping in Windows XP, exe4j does the job. exe4j helps you with starting your Java applications in a safe way, displaying native splash screens, detecting or distributing suitable JREs and JDKs, startup error handling and much more.
Check out the features of exe4J. Download(i would suggest you to download zip archive) the exe4J from here.
Ok now i’ll show you the steps to use exe4J for making exe. So download the exe4J zip archive and extract it to your preference location. Here i’ll be showing you how to create exe file for your java executable jar file. So lets first write a simple swing frame application which will just create a frame.
import javax.swing.*;
public class Test
{
public Test(){
JFrame frame=new JFrame(“test”);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,300);
frame.setVisible(true);
}
public static void main(String[] args){
new Test();
}
}
Ok save Test.java it in some folder ( I have saved it in E:/java_programs).
Now open your command prompt, navigate to the folder where Test.java file is saved and compile the Test.java using command javac Test.java
Now we’ll create a manifest file which will be needed to make an executable jar file. So this is the way you write your manifest file:
Main-Class: Test
First line on your manifest file will be Main-Class:<space>main-class(class file with the main method). then new line<enter>. You have to provide one new line after first line. Then save it as manifest.txt to the same folder where your Test.class file is saved.
Now we’ll create the executable jar file. Syntax is: jar -cvmf manifest.txt <name of jar file that you will create> class file/package if used
so open up your command prompt, navigate to the folder where Test.class file and manifest file is saved. Then enter command jar -cvmf manifest.txt test.jar Test.class and press enter. Yout executable jar file is created. You can check and test it(java -jar test.jar).
Now executable jar file is ready. So now i’ll show you the steps to make exe from your executable jar file.
STEP 1: Open the folder that u had extracted. Go to bin folder. Double click exe4j launcher. Now exe4j window will open up. Click next.
STEP 2: Choose “JAR in EXE” mode. Click next.
STEP 3: Now give the name for your application. I have given “app”. Then give the path of the location where you want to save the exe file. I have given the path of location where my class, manifest and jar file are located i.e E:/java_programs. Click next.
STEP 4: Now choose your executable type from list of radio buttons. In our case we will choose GUI application. Then give the name of exe file that we are making. I have provided test. Now check the boxes as shown in the screenshot. And Click next.
STEP 5: Now give the name of your main class. In our case its Test. Don’t put the .class extension, just give the name. Now don’t click next.
STEP 6: You can see the the gree plus button on above screenshot. Click that and a window will open up. Check the archive radio button above.Now we have to provide the executable jar file to the Archive, so browse the location where your executable jar file is saved. Add it. Click OK. Click next.
STEP 7: Now we have to configure the JRE. So provide the minimum jre version and maximum jre version to be used by the user. Then click next.
STEP 8: Now we have to configure splash screen (if you want to). I haven’t provided splash screen so i have chosed no splash screen. You can give your choice. Click next.
STEP 9: Now we have to configure messages like if you want to give error message when user does not have JRE installed in his/her machine. Click next.
STEP 10: Now the last step of the wizard. If you want to save the configuration then click save as. I haven’t saved the configuration so i clicked EXIT. Then it will ask me if i want to save the configuration. Click NO(if you want to save click yes). So Thats it. Done.
Now navigate the output folder where u have saved the exe file. In our case we provided the same folder where our jar and class files are located. In below screenshot you can see that test.exe file has been created.
Now double click test.exe and message box(“executable was created using evalustion version of exe4J”) will open. Just click ok. Then application will run. In our program we created a frame so frame will get displayed.
So thats it. You are off. Your exe has been created. Now you can distribute this exe to windows user. But i f u want to make a cross-platform distributed file then this methos is not recommended. This is for only windows environment.
Thanks.