Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当self包含.jar时,启动屏幕不工作_Java_Ant_Javafx - Fatal编程技术网

Java 当self包含.jar时,启动屏幕不工作

Java 当self包含.jar时,启动屏幕不工作,java,ant,javafx,Java,Ant,Javafx,我为javafx应用程序使用了一个闪屏功能。我使用javafxant任务按顺序运行fx:jar、fx:signjar、fx:deploy以生成jar文件、jnlp文件、html文件和nativebundle,包括“image”和“exe”。当通过双击将splash打包到.jar文件中时,它运行良好。 但是,当我通过运行.exe安装文件双击应用程序映像文件夹中的exe文件或安装后的快捷方式时,没有启动屏幕。为什么?exe文件不基于jar文件运行?谢谢您的帮助。我也遇到了同样的问题,并在我的fx:d

我为javafx应用程序使用了一个闪屏功能。我使用javafxant任务按顺序运行fx:jar、fx:signjar、fx:deploy以生成jar文件、jnlp文件、html文件和nativebundle,包括“image”和“exe”。当通过双击将splash打包到.jar文件中时,它运行良好。
但是,当我通过运行.exe安装文件双击应用程序映像文件夹中的exe文件或安装后的快捷方式时,没有启动屏幕。为什么?exe文件不基于jar文件运行?谢谢您的帮助。

我也遇到了同样的问题,并在我的fx:deploy中尝试了许多可能性(比如在fx:info下添加fx:jvmarg、fx:jvmuserarg和fx:splash),在我的INNO脚本中,我还尝试通过javapackager生成exe,甚至将图像格式更改为png、jpg、bmp,但是,当SplashScreen从一个自包含的exe包运行时,它不会显示任何内容。因此,我创造了自己的替代方案,可以帮助发现同样问题的人

主要类别:

            SplashScr splash = new SplashScr ();
            splash.setVisible(true);
            MainFrame mainFrame = new MainFrame();

            SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    Thread.sleep(2000);
                    return null;
                }

                protected void done() {
                    splash.setVisible(false);
                    mainFrame.setVisible(true);
                    splash.dispose();
                    mainFrame.startProcess(args);
                }
            };
            worker.execute();

我希望它对发现相同问题的人有用。

您是如何创建exe的?你用过Witch工具吗?exe的工作目录上下文是什么?它与图像有什么关系,或者与Jar有什么不同?谢谢你的回复。我使用javafxant任务来部署我的javafx应用程序。以下是javafx ant任务参考:如果您安装了Inno setup,则可以选择“nativeBundles”=“all”来创建exe和setup exe文件。所以这一切都是自动的。飞溅图像包含在jar文件中,jar文件也在jar的清单文件中指定。所以双击运行jar时会出现飞溅图像。我也遇到了同样的问题-您找到了解决方案吗?和
public class SplashScr extends JWindow {

  public SplashScr () {

    ImageIcon image = new ImageIcon(getClass().getResource("SplashScreen.png"));
    int width = image.getIconWidth();
    int height = image.getIconHeight();
    getContentPane().add(new JLabel("", image, SwingConstants.CENTER));
    setSize(width, height);
    setLocationRelativeTo(null);
  }
}