Problem with JAR + dxinput.dll

Hello

I was hoping for some input on a very annoying problem of mine. Feeling is it must have a simple solution… I did some searching this forum before posting, didn’t find any tip, so…:

I’ve made a simple game which uses JInput, more specifically I use a gamepad to play it. Everythings works as expected in my IDE (NetBeans) so no problem here. However, I’m trying to bundle everything in an executable JAR (in the unlikely event that someone actually wants to try it :)). This works almost as expected; code, images and sound are all OK, but the most important piece is missing, the gamepad functionality…

Both the plugins and native files are included in JAR (lib/native, lib/plugin, lib/runtime). Im using a class loader (http://www.jdotsoft.com/JarClassLoader.php) which handles the JAR creation. The docs concerning this loader states that all files, including native ones, can be placed at any location within the JAR; the loader will find them. But somehow the gamepad functionality is not there when running the JAR hmmm.

I have tried to manually set the java library path (absolute), to point at dxinput.dll, as follows:


try {
    System.setProperty("java.library.path", "c:/MinAppFolder/MinApp/"); 
    System.load("c:/MinAppFolder/MinApp/dxinput.dll"); 
    // also tried System.loadLibrary("dxinput.dll") here...
}
catch(UnsatisfiedLinkError e) {
    System.out.println(e);
}

The above code being placed first in the program main-method. It’s of course not ideal, but I did this just to test if I could get it to work at all…
No luck with this option either :confused: (I’m never getting UnsatisfiedLinkError though)

Have any of you experienced this problem aswell? I would really appreciate some help with this, feels like I’ve tried all options. What am I doing wrong?

/ Anders

Been looking around some more in this forum and it seems like many of you actually got this to work; being able to deploy through JWS etc, suggests that you either never had this problem, or have overcome it.

Looking forward to hearing your solutions :slight_smile: Want to get this up and running…so many hours…

/ Anders

Ok, it seems like a solution has arrived :slight_smile:

The best part is that the native files are actually located and loaded from within the JAR (which I didn’t think was easily doable). Not been setting a single java.library.path. I have yet to work out all the details, but I successfully managed to interact with my app (executed by JAR) through a gamepad.

First of all I have been using an old version of JInput (just used the same files I found in a tutorial (“jinputTutorialOne” I think). That version included only one dll file, dxinput.dll. I got the latest via link in “Getting started…” :). Found out that the Axis class (of older version) was removed so I had to modify (in the process of doing this :)) some methods in my app to make it work. Great relief to see the gamepad responding at last, when running my app-jar!

/ Anders