英文:
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.
专注分享java语言的经验与见解,让所有开发者获益!
评论