I'm making a basic game in Java using the LWJGL Library via Netbeans.

我正在通过Netbeans使用LWJGL库在Java中做一个基本的游戏。

I've created a library with the lwjgl, lwjgl_util, and jinput .jar's, and I added -Djava.library.path=C:\LWJGL\native\windows to the "Run" category in the project's properties.

我创建了一个包含lwjgl、lwjgl_util和jinput .jar的库,并添加了-Djava.library。路径=C:\LWJGL本地\windows到项目属性中的“运行”类别。

When I run the file in Netbeans, it runs perfectly with no issue. But when I run the .jar via double-clicking the file, nothing pops up (not even the momentary cmd error window, as far as I can tell). And when I run the file via command line, I get:

当我在Netbeans中运行这个文件时,它运行得非常完美,没有问题。但是当我通过双击文件来运行.jar时,什么也没有弹出(就我所能看到的而言,甚至连瞬间的cmd错误窗口都没有)。当我通过命令行运行文件时,我得到:

C:\Users\200160765>java -jar "C:\Users\200160765\Documents\NetBeansProjects\Game
\dist\Game.jar"
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.libr
ary.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at org.lwjgl.Sys$1.run(Sys.java:73)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
        at org.lwjgl.Sys.loadLibrary(Sys.java:82)
        at org.lwjgl.Sys.<clinit>(Sys.java:99)
        at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
        at game.Draw.createWindow(Draw.java:198)
        at game.Draw.init(Draw.java:214)
        at game.Draw.run(Draw.java:56)
        at game.Main.main(Main.java:9)

I've tried moving the DLL's and .jar library files around to the 'lib' folder in the same directory as Game.jar, and moving them to the same directory as Game.jar, but I get the same error. Could someone help me as to why I can't seem to get this working outside of netbeans?

我尝试将DLL和.jar库文件移动到与游戏相同的目录中的“lib”文件夹。将它们移动到与游戏相同的目录。jar,但是我得到了相同的错误。有人能帮我解释一下为什么在netbeans之外我还不能让它正常工作吗?

6 个解决方案

#1


9

you have to point the jvm to where the native files are located using a command line parameter -Djava.library.path="path/to/natives". You could use a batch (.bat) file to specify this and start your application for you.

您必须使用命令行参数djava .library.path=“path/to/native”将jvm指向本地文件所在的位置。您可以使用一个批处理(.bat)文件来指定这一点,并为您启动应用程序。

Alternatively you can use a tool like JarSplice to create a single executable jar file from all your jars and at the same time include your native files inside it. It automates the tricky part of specifying the natives manually and provides a nicer end user experience.

您也可以使用JarSplice这样的工具从所有jar中创建一个可执行的jar文件,同时在其中包含本地文件。它自动化了手工指定本机版本的棘手部分,并提供了更好的最终用户体验。

To use JarSplice just select your game.jar, lwjgl.jar, lwjgl_util.jar, and jinput.jar in the jars tab. Then all the *.dll, *.so, *.dylib and *.jnilib files in the natives tab. Add your main class on the class tab and create the single executable jar.

要使用JarSplice,只需选择您的游戏。lwjgl jar。lwjgl_util jar。jar和jinput。jar在jars选项卡中。然后所有的*。dll,*。所以,*。dylib和*。jnilib文件在本机选项卡中。在class选项卡上添加主类并创建单个可执行jar。

更多相关文章

  1. 新手求教RandomAccessFile读写文件到底写入的是什么?
  2. Java逐行读写TXT文件
  3. 第二届战神杯线上编程挑战赛月赛第二题:数字游戏(Java)
  4. 帮忙解析一下 java解析普通的文本文件,提取信息到execl文件中
  5. 如何从java获取spring配置文件名称
  6. [疯狂Java]NIO.2:walkFileTree、FileVisitor(遍历文件/目录)
  7. Java的Web项目中Web.xml配置文件元素详解
  8. Java操作ini文件 ,解决properties文件中无法读取换行及空格
  9. java基础IO删除文件夹文件

随机推荐

  1. Android(安卓)API 28 使用 android-async
  2. Android Wear Preview- 从通知上接收语音
  3. Android 开源框架的收集
  4. 网络书签about Android
  5. Android UI详解之动态布局
  6. android aidl通讯两个APP之间的应用
  7. android读写文件
  8. C# mono android 图片上传进度条实现
  9. android 2.2+ 完全退出程序的方法
  10. android SpannableString使用详解,替代多