罐头启动器极其缓慢

huangapple 未分类评论63阅读模式
标题翻译

Jar launcher excruciatingly slow

问题

我目前正在为学校的一个独立项目工作,在这个项目中,我正在制作一个曼德博集合的可视化程序。我已经有了一个基本版本的程序,并且想要将其打包成一个jar文件,在其他系统上进行测试。当我在我的Mac上进行测试时,我注意到从终端启动的工作方式是正常的(就像在IntelliJ或Code中一样):

java -jar Mandy.jar

然而,双击可执行文件会以极慢的速度执行相同的程序。据我所知,每个绘图周期的速度比正常情况下慢了100多倍(我将很快发布一个时间分析结果)。

我已经四处寻找答案,但一直没有找到解释。我猜想这可能与macOS的jar启动器有关,但关于这方面的信息很少。

有人知道是什么原因引起的吗?提前谢谢。

以下是代码和可执行的jar文件,如果有人想要亲自查看:仓库链接

编辑:在仅安装了JDK 11的macOS系统上出现了这种情况。所有其他的JRE和JDK都已被卸载。

值得注意的是,当使用Java 8进行编译和执行时,不管启动方法如何,都会出现相同的缓慢情况。

英文翻译

I'm currently working on an independent project for school, where I make a visualizer for the Mandelbrot set. I have a basic version of the program, and wanted to package it into a jar and test it on other systems. When I tested on my mac, I noticed that launching from terminal worked normally (just like from intellij or code)

java -jar Mandy.jar

However, double clicking the executable executes the same program at a snail's pace. From what I can tell, over 100x slower per paint cycle (I will post a time profile soon)

I've looked all over, and have been unable to find an explanation for this. I assume it has to do with macos's jar launcher, but there was very little information available on it.

Does anyone have any idea what could cause this? Thanks in advance.

Here is the code and executable jar in case someone wanted to see for themselves: repo

Edit: This is being experienced on a macos system with (only) jdk 11 on it. All other JRE's and JDK's have been uninstalled.

It is noteworthy that when compiled and executed with java 8, the same slowness was experienced regardless of launch method.

答案1

得分: -1

很可能您的系统上安装了多个JDK或JRE版本,而在命令行上运行java -jar会使用不同的java可执行文件,与从Finder中双击jar文件运行时不同。

在Finder中右键单击jar文件以获取其他打开选项,或者使用“获取信息”选项,然后查看用于运行它的可执行文件。我敢打赌,这个可执行文件与命令行上的which java输出不匹配。找到一种方法卸载该JVM,或者更改用于运行jar文件的应用程序,然后在“获取信息”小部件中选择“适用于所有此类文件”选项。

英文翻译

Most likely you have more than one JDK or JRE installed on the system, and running java -jar on the command line uses a different java executable than double clicking a jar from the finder.

Right click on the jar in the finder for other open options, or use 'get info', then check out what executable is being used to run it. I bet it will not match with what which java prints on the command line. Find a way to uninstall that JVM, or change the app to be used to run jar files and then click the 'for all such files' option in the get info widget.

huangapple
  • 本文由 发表于 2020年3月4日 05:04:35
  • 转载请务必保留本文链接:https://java.coder-hub.com/60515484.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定