简体   繁体   English

我的Java Slick游戏Jar文件无法打开

[英]My Java Slick game Jar file will not open

I have made a simple GUI using slick and lwjgl, I am using eclipse and have imported my jars, natives and images to my Java build path, I export my code as a jar file and get a jar file on my desktop, I try open it with SE Binary and it loads for a little while then nothing happens. 我使用slick和lwjgl制作了一个简单的GUI,使用eclipse,并将jar,本机和图像导入到Java构建路径,将代码导出为jar文件,并在桌面上获取了jar文件,然后尝试打开使用SE Binary加载它,然后加载一会儿,然后什么也没有发生。

It may have something to do with how I have imported them into my build path, I will try explain, I have inside my Java project two additional folders that I have created, they are lib and res, res holds all of my images and lib holds two other folders called jars and natives, jars holds two jar files (slick and lwjgl) and natives holds 4 other folders (windows, linux, mac, solaris natives), I imported my 2 jar files into the build path using the add jars option, I then imported my res file using the add class folder option and after that using the same option I imported the lib folder, I then exported it and now it doesn't open. 这可能与我将它们导入到构建路径中的方式有​​关,我将尝试解释一下,我在Java项目中有另外两个我创建的文件夹,它们是lib和res,res存放我所有的图像和lib拥有另外两个名为jars和natives的文件夹,jars拥有两个jar文件(slick和lwjgl),而natives拥有另外4个文件夹(windows,linux,mac,solaris natives),我使用添加jar将2个jar文件导入到构建路径中选项,然后使用添加类文件夹选项导入我的res文件,然后使用导入lib文件夹的相同选项导入我的res文件,然后将其导出,但现在无法打开。

It may be worth mentioning that before I export my jar files from eclipse I get the following pop up message: The operation repacks referenced libraries. 值得一提的是,在我从eclipse导出我的jar文件之前,我得到以下弹出消息:该操作重新打包了引用的库。

It seems that lwjgl can't use the native libraries when they are inside a jar archive. 当lwjgl放在jar存档中时,似乎无法使用它们。

The solution is to unpack your natives folder either into some install directory or a temporary directory. 解决方案是将本机文件夹解压缩到某些安装目录或临时目录中。 Then, before you use any lwjgl function, you need to set the new path to the natives. 然后,在使用任何lwjgl函数之前,需要设置本机的新路径。 For example with the files unpacked in "lib/native" I use 例如,使用“ lib / native”中解压缩的文件

System.setProperty("org.lwjgl.librarypath", (new File("lib/native")).getAbsolutePath());
System.setProperty("java.librarypath", (new File("lib/native")).getAbsolutePath());
System.setProperty("net.java.games.input.librarypath", (new File("lib/native")).getAbsolutePath());

This seems to be the easiest solution. 这似乎是最简单的解决方案。 For example minecraft (which uses lwjgl) unpacks the natives to "%appdata%.minecraft\\bin\\natives" (on windows, ~ instead of %appdata% on linux). 例如,minecraft(使用lwjgl)将本机解压缩为“%appdata%.minecraft \\ bin \\ natives”(在Windows上,是〜而不是在Linux上是%appdata%)。

Edit: a very related wiki page: http://lwjgl.com/wiki/index.php?title=Distributing_Your_LWJGL_Application 编辑:一个非常相关的Wiki页面: http : //lwjgl.com/wiki/index.php?title=Distributing_Your_LWJGL_Application

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

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