JInput “no jinput-dx8 in java.library.path” Error

淺唱寂寞╮ 提交于 2019-12-11 08:37:07

问题


Hi I'm trying to make a game in java that gives users the option to a joystick or gamepad to control movement. So I found something called "JInput" that is suppose to make it easy to detect all connected game controllers. The problem is that when I run it in Eclipse I get the following error: "java.lang.UnsatisfiedLinkError: no jinput-dx8 in java.library.path".

My code is the following:

import net.java.games.input.*;


public class ListControllers 
{

  public static void main(String[] args) 
  {

    System.out.println("JInput version: " + Version.getVersion());

    ControllerEnvironment ce =
         ControllerEnvironment.getDefaultEnvironment();

    Controller[] cs = ce.getControllers();

    if (cs.length == 0) {
      System.out.println("No controllers found");
      System.exit(0);
    }

    // print the name and type for each controller
    for (int i = 0; i < cs.length; i++)
      System.out.println(i + ". " +
             cs[i].getName() + ", " + cs[i].getType() );

  } // end of main()


} // end of ListControllers class

I'm currently developing in Windows 7 environment. Any help would be really appreciated.


回答1:


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.



来源:https://stackoverflow.com/questions/2051723/jinput-no-jinput-dx8-in-java-library-path-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!