Saturday, November 12, 2005

This is a simple step by step tutorial that explains how to setup Eclipse on Windows for SDLJava:
  1. 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).
  2. Extract to any directory (e.g. C:\Java\sdljava-0.9.1).
  3. Click Start -> Settings -> Control Panel -> System -> Advanced -> Environment Variables and append C:\Java\sdljava-0.9.1\lib to the Path system variable.
  4. Go to C:\Java\sdljava-0.9.1\bin and execute testsprite.bat - If it works, congratulations, 75% done.
  5. Open Eclipse, create a new project, add a source file to it and paste the following into it:
  6. 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();
    }
    }

    }

  7. Right click the source file and choose Run As ... Run.
  8. If there isn't already an entry below "Java Application", create one. Ensure that the main class is set to "HelloSDL".
  9. Switch to the Arguments tab and add the following to VM arguments: -Djava.library.path=C:\Java\sdljava-0.9.1\lib
  10. 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.
  11. Run the project. If it works, that's all there is to it!
Make sure you consult the SDL documentation and the sample source code that ships with SDLJava (testsrc\testsuite).

3 Comments:

Blogger Jason said...

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

9:43 AM  
Blogger Bondey said...

i'm using a 64 bit architecture (win 7) and have this problem:
Can't load IA 32-bit .dll on a AMD 64-bit platform.
there are any solution?

2:54 AM  
Blogger Bondey said...

This comment has been removed by the author.

2:55 AM  

Post a Comment

<< Home