可执行 Jars 运行速度非常慢

发布于 2024-07-14 20:27:09 字数 485 浏览 5 评论 0原文

我已经完成了几个项目并将它们打包成 jar 文件,但我注意到我的 jar 文件运行速度比在 IDE 中慢得多。

我使用 Eclipse 来编译和运行我的程序。 在 Eclipse 中,一切正常。 当我将项目打包为可运行的 Jar 并通过双击执行它时,一切仍然有效。 但是当我有动画时,程序运行极其缓慢。 我现在每秒大约 2 帧,而不是 Eclipse 中的每秒 30 帧。 动画非常滞后。

有趣的是,当我从命令提示符运行同一个 Jar (java -jar MyCode.jar) 时,延迟消失了,我的程序正常工作。

我目前不知道是什么导致了这个问题。 我的计算机运行的是 Windows Vista。 我正在使用最新版本的 JRE 和 JDK。 我的程序包含一个动画,没什么花哨的。

谢谢

解决方案: 我的计算机上有多个不同版本的 Java,并且使用了不正确的版本。

I've done several projects and packaged them into jar files, but I've noticed that my jar files run much more slowly than in my IDE.

I use Eclipse to compile and run my programs. In Eclipse, I have everything working. When I package my project as a runnable Jar and execute it by double-clicking, everything still works. But when I have animation, the program runs extremely slowly. Instead of 30 frames per second in Eclipse, I now get about 2 frames per second. The animation is very laggy.

Interesting thing is, when I run the same Jar from the command prompt (java -jar MyCode.jar), the lag disappears and my program works as normal.

I currently have no idea what's causing this problem. My computer is running Windows Vista. I'm using the latest version of JRE and JDK. My program contains an animation, nothing fancy.

Thanx

Solution:
There were several different versions of Java on my computer and an incorrect version was used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜空下最亮的亮点 2024-07-21 20:27:09

Windows 附带的 java.exe 版本已经非常过时。
通过更改 .jar 扩展名与更新的 JVM 的关联,您应该会看到很大的改进。

The version of java.exe that comes with Windows is very out of date.
By changing the association of the .jar extension to the more recent JVM you should see much improvement.

闻呓 2024-07-21 20:27:09

您还可以考虑任何正在运行的防病毒软件是否会影响性能。 某些软件将 .jar 文件视为 .zip 存档,并进行相应的扫描。 它们的 shell 集成也可以解释双击和命令行之间的区别。

You may also consider whether any running antivirus software is affecting performance. Some software treats .jar files as the .zip archives that they are and scans accordingly. Their shell integration might explain the difference between double-clicking and command line as well.

一身软味 2024-07-21 20:27:09

可能您已将双击与某些“不良”JVM 版本相关联。

我要做的是使用 SysInternals 的 processxp 来查看是什么您的应用程序正在使用的解释器。 可能只需将其更改为与命令行和 Eclipse 相同的使用方式即可。

检查并查看两者是否使用相同的 JVM(ProcessXP 中有一个列名称命令行,比较该值)

我希望这会有所帮助。

Probably you have associated the double click with some "bad" JVM version.

What I would do is to use processxp from SysInternals to see what's the interpreter your app is using. Probably is only matter to change it to use the same as the command line and the eclipse.

Check that and see if both uses the same JVM ( there's a column names command line in ProcessXP, compare that value )

I hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文