简体   繁体   English

JInput“ java.library.path中没有jinput-dx8”错误

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

Hi I'm trying to make a game in java that gives users the option to a joystick or gamepad to control movement. 嗨,我正在尝试用Java开发一款游戏,使用户可以选择操纵杆或游戏手柄来控制运动。 So I found something called "JInput" that is suppose to make it easy to detect all connected game controllers. 因此,我发现了一个名为“ JInput”的东西,它可以简化检测所有连接的游戏控制器的过程。 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". 问题是,当我在Eclipse中运行它时,出现以下错误:“ java.lang.UnsatisfiedLinkError:java.library.path中没有jinput-dx8”。

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. 我目前在Windows 7环境中进行开发。 Any help would be really appreciated. 任何帮助将非常感激。

You should set java.library.path property to point to the directory containing native dlls of JInput. 您应该将java.library.path属性设置为指向包含JInput本机dll的目录。 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. 您可以通过在命令行或Eclipse中“运行配置”对话框的“ VM参数”字段中添加-Djava.library.path=x (其中x是您的路径)来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM