简体   繁体   English

在Ubuntu上运行JavaFX jar

[英]Running JavaFX jar on Ubuntu

I'm unable to run jar files of JavaFX applications on my Ubuntu virtual machine and I don't know why. 我无法在我的Ubuntu虚拟机上运行JavaFX应用程序的jar文件,我不知道为什么。 It just says that it can't find the main file of the jar. 它只是说它找不到jar的主文件。 Other jars of for example Swing applications seem to work fine. 其他罐子例如Swing应用程序似乎工作正常。 This is what I get when I run java -version on Ubuntu: 这是我在Ubuntu上运行java -version时得到的结果:

在此输入图像描述

It seems like it has Java 8 where JavaFX should be included by default, so why can't I run the jars? 看起来它有Java 8默认情况下应该包含JavaFX,为什么我不能运行jar?

Edit: The jar consists of one class that looks like this: 编辑:jar包含一个类如下:

import javafx.application.Application;
import javafx.stage.Stage;

public class Main extends Application {
        public static void main(String[] args) {launch(args);}
        public void start(Stage ps) {
                ps.show();
        }
}

And it was created with the command jar cfe javafxjar.jar Main Main.class 它是使用命令jar cfe javafxjar.jar Main Main.class

The jar executes without problems on Windows 10, but fails with this message on Ubuntu: jar在Windows 10上执行没有问题,但在Ubuntu上失败并显示此消息: 在此输入图像描述

Today I've also bumped into this problem. 今天我也碰到了这个问题。

In my case the reason was OpenJDK. 在我的情况下,原因是OpenJDK。 It does not contain OpenJFX by default. 默认情况下它不包含OpenJFX。

The solution was: sudo apt-get install openjfx 解决方案是: sudo apt-get install openjfx

And now all works like a charm. 现在一切都像魅力一样。

Could it be due to the JAVA_TOOL_OPTIONS: 可能是由于JAVA_TOOL_OPTIONS:

$ unset JAVA_TOOL_OPTIONS
$ java -jar javafxjar.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM