gpt4 book ai didi

java - JInput "no jinput-dx8 in java.library.path"错误

转载 作者:行者123 更新时间:2023-11-29 06:23:24 28 4
gpt4 key购买 nike

您好,我正在尝试用 Java 制作一款游戏,让用户可以选择操纵杆或游戏 handle 来控制移动。所以我发现了一个叫做“JInput”的东西,它可以很容易地检测到所有连接的游戏 Controller 。问题是当我在 Eclipse 中运行它时出现以下错误:“java.lang.UnsatisfiedLinkError:java.library.path 中没有 jinput-dx8”。

我的代码如下:

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 环境中进行开发。非常感谢任何帮助。

最佳答案

您应该将 java.library.path 属性设置为指向包含 JInput 的 native dll 的目录。您可以通过将 -Djava.library.path=x (其中 x 是您的路径)添加到命令行或“运行”的“VM 参数”字段来实现Eclipse 中的配置”对话框。

关于java - JInput "no jinput-dx8 in java.library.path"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2051723/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com