[英]Why does my game run fine on Linux, but not in Windows? (Java .jar)
When deploying my game in a .jar, it runs fine with no errors on Linux / Mac. 在.jar中部署游戏时,它在Linux / Mac上运行正常,没有错误。
However on Windows, (specifically testing Windows 10 as of yet), I get these errors on launch and then a blank screen in my JFrame: 但是,在Windows上(具体来说,到目前为止已测试Windows 10),启动时出现这些错误,然后在JFrame中出现黑屏:
Exception in thread "PooledThread7" java.lang.IllegalStateException: Buffers have not been created
at sun.awt.windows.WComponentPeer.getBackBuffer(Unknown Source)
at java.awt.Component$FlipBufferStrategy.getBackBuffer(Unknown Source)
at java.awt.Component$FlipBufferStrategy.flip(Unknown Source)
at java.awt.Component$FlipBufferStrategy.show(Unknown Source)
at engine.Game$Render.render(Game.java:250)
at engine.Game$Render.run(Game.java:167)
at engine.PooledThread.run(ThreadPool.java:89)
and 和
java.io.FileNotFoundException: res\maps\map.txt (The system cannot find the path specified)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at engine.testMapCreator.init(testMapCreator.java:69)
at engine.Game.init(Game.java:126)
at engine.Game.main(Game.java:80)
So it appears Windows is not liking my thread pool rendering, and for some reason while it finds the map files inside a .jar on Linux, it does not find them when on Windows. 因此,Windows似乎不喜欢我的线程池渲染,并且由于某种原因,虽然在Linux上在.jar中找到映射文件,但在Windows上却找不到它们。
... So much for "Write once, Run anywhere", right? ...“写一次,随处运行”就这么多了,对吧? What could be the problems?
可能是什么问题?
edit: This is how I am reading the map.txt files: 编辑:这就是我阅读map.txt文件的方式:
InputStream is = Game.class.getResourceAsStream("/map.txt")
Scanner scanner = new Scanner(is);
(for loops to iterate over the data)
For the first error probably adding -Dsun.java2d.d3d=false
to the command line will help (disable usage of Direct3D for 2D rendering). 对于第一个错误,可能在命令行中添加
-Dsun.java2d.d3d=false
会有所帮助(禁用将Direct3D用于2D渲染)。 Eg: 例如:
java -Dsun.java2d.d3d=false -jar some.jar java -Dsun.java2d.d3d = false -jar some.jar
As for the second one, we would need to see how you write the files (FileWriter is mentioned), it might be eg that you don't have res\\maps
directory. 至于第二个,我们将需要查看如何编写文件(提到了FileWriter),例如,您可能没有
res\\maps
目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.