SwingFXUtils.toFXImage 在 JAR 中运行缓慢

huangapple 未分类评论45阅读模式
英文:

SwingFXUtils.toFXImage is Running Slowly in Jar

问题

我有一个使用IntelliJ和Maven构建的简单Java应用程序,运行以下代码:

File myFile = new File("/Users/jason/Documents/TiffImages/bigTiff.tiff");

BufferedImage image = null;
try {
	image = ImageIO.read(myFile);
} catch (IOException e) {
	String stacktrace = ExceptionUtils.getStackTrace(e);
	System.out.println(stacktrace);
}

System.out.println("getting ready to load image");

Image outImage = SwingFXUtils.toFXImage(image, null);

System.out.println("loaded image");

bigImageView.setImage(outImage);

当我使用Maven/javafx:run从IntelliJ运行应用程序时,上述代码几乎会立即运行。但是,当我构建一个Jar文件并从命令行运行时,上述代码需要超过10秒钟。我似乎无法找出原因。

导致花费10秒钟的具体行是SwingFXUtils.toFXImage那一行。

是否有其他人遇到过这样的减速?我似乎无法解决这个问题。

英文:

I have a simple Java application built using IntelliJ and Maven that runs the following:

File myFile = new File("/Users/jason/Documents/TiffImages/bigTiff.tiff");

BufferedImage image = null;
try {
	image = ImageIO.read(myFile);
} catch (IOException e) {
	String stacktrace = ExceptionUtils.getStackTrace(e);
	System.out.println(stacktrace);
}

System.out.println("getting ready to load image");

Image outImage = SwingFXUtils.toFXImage(image, null);

System.out.println("loaded image");

bigImageView.setImage(outImage);

When I run the application from IntelliJ using Maven/javafx:run, the above code runs nearly instantaneously. But when I build a Jar and run it from command line, the above code takes more than 10 seconds. I can't seem to figure out why.

The specific line that is taking 10 seconds is the SwingFXUtils.toFXImage line.

Has anyone else experienced such a slow down? I can't seem to figure this one out.

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

发表评论

匿名网友

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

确定