问题描述
我正在尝试用Java制作一个游戏,使用户可以选择操纵杆或游戏手柄来控制运动.因此,我发现了一个名为"JInput"的东西,它可以简化检测所有连接的游戏控制器的过程.问题是,当我在Eclipse中运行它时,出现以下错误:"java.lang.UnsatisfiedLinkError:java.library.path中没有jinput-dx8".
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".
我的代码如下:
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
我目前正在Windows 7环境中进行开发.任何帮助将不胜感激.
I'm currently developing in Windows 7 environment. Any help would be really appreciated.
推荐答案
您应该设置java.library.path
属性以指向包含JInput本机dll的目录.您可以通过在命令行或Eclipse中运行配置"对话框的"VM自变量"字段中添加-Djava.library.path=x
(其中x
是您的路径)来做到这一点.
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.
这篇关于JInput"java.library.path中没有jinput-dx8"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!