0

I'm trying to listen keyboard events in Java by using a third-party library from "net.java.games.input". When I run my code in Eclipse, it works fine. But when I build my project and run the .jar, it does not. The reason I guess, the library needs some .dll files to listen my keyboard and they don't work in .jar.

Here's my code example;

ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] ca = ce.getControllers();

So, what should I do to make this work in a .jar?

Thanks.

josh
  • 409
  • 1
  • 5
  • 18
  • i have a look to your librairy (here : https://github.com/sgothel/jinput/tree/master/coreAPI) i saw no dll involved , even it work on linux so i am pretty sure that they are none , i think that more a build issue . how do you generate you jar ? can you make a simple sample of code that fail or the exception throw? – Arnault Le Prévost-Corvellec Jun 19 '18 at 11:54
  • @ArnaultLePrévost-Corvellec When I run the code without .dll files, I got this exception; java.lang.UnsatisfiedLinkError: no jinput-dx8_64 in java.library.path – josh Jun 19 '18 at 13:22
  • your issue will be the same if eclipse didn't did this automatically^^ – Arnault Le Prévost-Corvellec Jun 19 '18 at 15:35

2 Answers2

0

You can use System.loadLibrary() to let the JVM loading your dll or System.load() to load file from a specific path:

static {
    System.load("PATH/TO/file.dll");
}
Halayem Anis
  • 7,654
  • 2
  • 25
  • 45
0

so your issue is relative to this

JInput "no jinput-dx8 in java.library.path" Error

You should set java.library.path property to point to the directory containing native dlls of JInput. You can do it by adding -Djava.library.path=x (where x is your path) to the command line or to the "VM arguments" field of "Run configurations" dialog in Eclipse.

answered Jan 12 '10 at 19:48

axtavt 198k31421427

you can also at the beginnning of your main do this

System.setProperty("java.library.path", System.getProperty("java.library.path")+";thePathOfYourDll");