1

I'm currently working on a game based on Slick2D, but I ran into a problem.
When I try to run my game (no matter whether from dist or ide), I get the following error:

java.lang.UnsatisfiedLinkError: no jinput-linux64 in java.library.path

My directory structure is as following:
./lib contains all the .jar's for libraries
./natives contains the .dll's, .so's and .jnilib's

If I go to project options, and add -Djava.library.path=./natives to VM options, it works properly. But in that case, I'd need to have all the native libraries inside the root folder of the dist. So I want to have a separate folder for all the natives, so my first line in my main has this:

System.setProperty("org.lwjgl.librarypath", System.getProperty("user.dir") + "/natives");

But for some reason, this doesn't give a standard linking error (e.g. lwjgl not found) but for some reason picks jinput-linux64, but jinput is added as a library and is in the natives folder.

Is there anything I've done wrong or is there a better approach to distributing my game effectively overall?

Thank you !

argoneus
  • 1,097
  • 2
  • 13
  • 24

1 Answers1

0

What is wrong with placing the native libraries in your distribution? You cannot rely on your audience to have the libraries your application needs. Here is how I distribute stuff I make with slick:

MyFancyGame (Top directory)
-- libraries (mine and slick and lwjgl jars here)
   -- lwjgl 
      -- native (dlls and so files go in here)

In the top directory I include a shell script & a batch file which contains one line:

java -ea -Djava.library.path="libraries/lwjgl/native/" -cp  "libraries/*" com.MyGame.Main

This works on every computer I deploy to so long as they have java installed.

anio
  • 8,903
  • 7
  • 35
  • 53
  • But that's what I do. Except I have a separate 'natives' folder to the 'lib' folder, not inside it. And this thing with batch files, won't that make distribution to tech-not-savvy people worse? – argoneus Jun 08 '12 at 13:10
  • People don't even know its a batch file, the extensions are hidden in Windows. Just name it something like "RunGame". People will automatically double click it and it will work. Double clicking on a jar doesn't work. Using webstart totally sucks. Other than running through a bunch of hoops to get your java program to be a windows executable, I find the batch file to be the most convenient and reliable solution for windows. You don't have to worry about your Linux users, they generally don't need to be spoon fed. – anio Jun 08 '12 at 13:15
  • If you really don't want a batch file, you can create a shortcut to your jar and place the java -ea blah blah command in there. That also works on windows. – anio Jun 08 '12 at 13:25