This is a simple step by step tutorial that explains how to setup Eclipse on Windows for SDLJava:
- Download sdljava-0.9.1-win32-bin.zip and optionally sdljava-0.9.1-src.zip (It contains the source code for the samples, very handy).
- Extract to any directory (e.g. C:\Java\sdljava-0.9.1)
. - Click Start -> Settings -> Control Panel -> System -> Advanced -> Environment Variables and append C:\Java\sdljava-0.9.1\lib to the Path system variable.
- Go to C:\Java\sdljava-0.9.1
\bin and execute testsprite.bat - If it works, congratulations, 75% done. - Open Eclipse, create a new project, add a source file to it and paste the following into it:
- Right click the source file and choose Run As ... Run.
- If there isn't already an entry below "Java Application", create one. Ensure that the main class is set to "HelloSDL".
- Switch to the Arguments tab and add the following to VM arguments: -Djava.library.path=C:\Java\sdljava-0.9.1\lib
- Open the project properties, select Java Build Path -> Libraries and click on Add external JARs, then choose C:\Java\sdljava-0.9.1\lib\sdljava.jar and click Open.
- Run the project. If it works, that's all there is to it!
import sdljava.*;
import sdljava.video.*;
class HelloSDL {
public static void main(String[] args) {
final String caption = "Hello, SDL!";
System.out.println(caption);
try {
SDLMain.init(SDLMain.SDL_INIT_VIDEO);
SDLVideo.wmSetCaption(caption, caption);
SDLSurface screen = SDLVideo.setVideoMode(640, 480, 24, 0);
java.lang.Thread.sleep(2500);
} catch(Exception e) {
e.printStackTrace();
} finally {
SDLMain.quit();
}
}
}

1 Comments:
You are forgetting, that you have to either put the directory containing SDL.dll into your class path or put the SDL.dll in the same directory as the sdljava.dll. At least I had to do this when setting it up with Eclipse 3.4.1 on XP and Vista
Post a Comment
<< Home