可执行.jar未运行JavaFX-Ecliipse [英] Executable .jar not running JavaFX - Ecliipse

查看:64
本文介绍了可执行.jar未运行JavaFX-Ecliipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JDK版本-jdk-13.0.2:添加了环境变量以及路径变量

JDK Version - jdk-13.0.2 : environmental variable added as well as path variable

JFX版本-javafx-sdk-13.0.2:添加了环境变量以及路径变量

JFX Version - javafx-sdk-13.0.2 : environmental variable added as well as path variable

Eclipse版本-2019-12-R:已安装e(fx)clipse插件:场景构建器

Eclipse Version - 2019-12-R : e(fx)clipse plugin installed : scene builder

操作系统-Windows 10

OS - Windows 10

现在在eclipse中,我已经配置了一些东西以允许JavaFX在IDE中运行.因此,我将列出我在IDE配置中所做的事情:

Now inside eclipse I have configured some things to allow JavaFX to run inside the IDE. So I will list what I have done inside the IDE configurations:

窗口>首选项> Java>已安装的JRE>在标准VM"选项> VM参数-模块路径"C:\ Program Files \ Java \ javafx-sdk-13.0"下添加了jdk-13.0.2. 2 \ lib-add-modules javafx.controls,javafx.fxml .

Window > Preferences > Java > Installed JRE's > Added jdk-13.0.2 under "Standard VM" option > VM Argument --module-path "C:\Program Files\Java\javafx-sdk-13.0.2\lib" --add-modules javafx.controls,javafx.fxml .

窗口>首选项> Java>构建路径>用户库>创建了一个包含 javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web的新库,javafx-swt .jar文件.

Window > Preferences > Java > Build Path > User Libraries > Created a new library containing javafx.base, javafx.controls, javafx.fxml, javafx.graphics, javafx.media, javafx.swing, javafx.web, javafx-swt .jar files.

对于单个项目,我仍然必须将新的用户库添加到类路径",因此我: 右键单击项目文件夹>属性> Java构建路径>库>删除默认的JavaFX SDK文件夹(不包含.jar文件)>添加新库>用户库>选择我创建的包含.jars的JavaFX库.此时,我可以调试并在IDE中运行任何Javafx.

For the individual projects I still have to add the new user library to the "class-path" so to do so I: Right-click Project folder > Properties > Java Build Path > Libraries > Delete the default JavaFX SDK folder (doesn't contain .jar files) > Add New Library > User Library > Select my created JavaFX library that contains the .jars. At this point I can debug, and run anything Javafx inside the IDE.

这两个测试用例只是300x300盒子的基本构建,其中没有其他组件(在弄清楚整个项目之前,试图弄清楚这一点).它们之间的区别仅是1个包含module-info.java(在创建项目时创建了一个模块). module-info.java包含:

Both test cases are just the basic build of 300x300 box with no other components in them (ruined an entire project before hand trying to figure this out). The difference between them is only 1 contains a module-info.java (created a module when project was created). The module-info.java contains:

module testing {
    exports application;
    requires javafx.graphics;
    requires javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.media;
    requires javafx.swing;
    requires javafx.swt;
    requires javafx.web;
}

另一个"Testing2"没有模块info.java,并且在项目创建时未创建(未选中框).当我尝试使用Runnable Jar选项导出"它们中的任何一个,然后将所需的库提取到生成的jar中"时,它将导出,并显示以下错误:重复条目:module-info.class .哪个令人困惑,因为"Testing2"不应包含任何模块?如果我使用将所需的库打包到生成的jar中"进行导出,则在导出时都不会出现任何错误,但是单击.jar文件本身会打开cmd框约0.5秒钟,然后关闭并且不执行任何其他操作.如果在导出时使用单独的库文件夹,则相同.尝试从命令行打开时,出现无法访问Jarfile \ path \ jar.jar",然后以管理员身份打开cmd时,出现缺少Javafx运行时组件".我已经

The other "Testing2" does not have a module-info.java and one was not created when the project was (unchecked box). When I try to "export" either of them using Runnable Jar option then "extract required libraries into generated jar" it exports with the following error : duplicate entry: module-info.class . Which is confusing because the "Testing2" shouldn't have any module? If I export using the "Package required libraries into generated jar" I get no error upon export for either, but the .jar file itself when clicked opens the cmd box for about 0.5 seconds, closes and does nothing else. Same if I use a separate folder for libraries when exporting. Trying to open from the command line I get "Unable to access Jarfile \path\jar.jar", and then if I open cmd as admin I get "Missing Javafx Runtime components" && I have gotten

`Graphics Device initialization failed for :  d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
        at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
        ... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.RuntimeException: No toolkit found
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)`enter code here`
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:830)


现在,在某些发现的答案中,我唯一无法完全验证的就是清单".到目前为止,我一直以为eclipse会自动创建一个,当我在导出时选择启动配置时,我选择的是我的主类的入口点.我也无法访问它,当我搜索如何在eclipse中创建一个字面意义时,每个人的答案都是"eclipse会自动为您完成",或者使用的是5年以上的版本,而我的屏幕操作却只是我自己在最新版本的IDE中没有.如果有人可以给我一些关于实际可能出问题的见解,我将不胜感激.谢谢!


Now the only thing I have not been able to completely test out in some of the answers I have found is the "manifest". So far I have been under the impression that eclipse automatically creates one and when I choose the launch configuration at time of exporting I am choosing the entry point with my main class. I also have not been able to access one, and when I searched for how to create one in eclipse literally everyones answers are "eclipse does it for you automatically" or are using a 5+ year old version that I has screen steps that I simply do not have in the newest version of the IDE. If anyone could give me some insight on what might actually be going wrong here I would appreciate it very much. Thank you!

推荐答案

好的,我已经弄清楚了(至少对我来说).我希望这对将来的任何人有帮助.因此,我进入了命令提示符,并将目录更改为

Alright I have figured it out (at least for me). I hope this helps anyone in the future. So I went into command prompt and changed my directory to where the .jar file was located by

cd path\to\file.jar

为方便起见,我保存到了桌面,因此它看起来像cd desktop

For ease I saved to desktop so it looked like cd desktop

接下来,我通过

set PATH_TO_FX="path\to\JavaFX\lib"

对于我来说,这看起来像set PATH_TO_FX="C:\Program Files\Java\javafx-sdk-13.0.2\lib",这是重要的一步,如果您不设置路径,则.jar文件将不会打开!

In my case it looked like set PATH_TO_FX="C:\Program Files\Java\javafx-sdk-13.0.2\lib" This is an important step, if you don't set the path the .jar file will not open!

然后,我添加了Eclipse中所需的VM参数,以使javaFX运行(至少与jdk13和jfx13一起运行),

Then I added the VM arguments that are needed in Eclipse to get javaFX to run (at least with jdk13 and jfx13) which looked like this

java -jar --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml Testing.jar

显然,我和许多其他人忘记了VM参数不会随.jar文件一起导出.您需要使用上述命令行修改的唯一内容是jfx \ lib文件夹的路径以及.jar文件的名称.我展示了我的样子,如果有人在命令提示符下感到困惑时,他们会有一个参考点.但是,仍然不能通过双击.jar文件来使其工作.我正在为此解决方案,并对此进行了编辑以反映该方法.

Apparently, I and many others keep forgetting that the VM arguments do not export with the .jar file. The only things you should need to modify with the above command lines are the paths to your jfx\lib folder, and the name of .jar file. I showed how mine looked so if someone gets confused working in the command prompt they have a reference point. However, this still doesn't allow it to work by double clicking the .jar file. I am working on a solution for that and I edit this to reflect that method as well.

这篇关于可执行.jar未运行JavaFX-Ecliipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆