JavaFX:无法在linux上找到或加载主类

时间:2022-10-21 15:57:20

I've developed a program in Windows with Java(FX) using Intellij Idea and that worked just fine, I then exported the artifact (jar) and there was no problem running it on Windows (both with the console and double clicking it).

我使用Intellij Idea在Windows中使用Java(FX)开发了一个程序,并且运行得很好,然后我导出了工件(jar),在Windows上运行它没有问题(使用控制台并双击它)。

I've then copied it to my Ubuntu VM, but there it says

然后我将它复制到我的Ubuntu VM,但它说

Error: Could not find or load main class sample.Main

This is the Manifest:

这是清单:

Manifest-Version: 1.0
Main-Class: sample.Main

The JAR file structure looks like this:

JAR文件结构如下所示:

test.jar
--- META-INF
--- --- MANIFEST.MF
--- org
--- --- json
--- --- --- // json library
--- sample
--- --- Contacts.class
--- --- Controller.class
--- --- Main.class
--- --- sample.fxml

2 个解决方案

#1


7  

Ubuntu, like Debian, has a separate package for OpenJFX (OpenJDK's implementation of JavaFX). Why this is the case, when JavaFX is an integral part of the JRE - I do not know, but your problem should be solved by installing the OpenJFX package:

像Debian一样,Ubuntu有一个单独的OpenJFX包(OpenJDK的JavaFX实现)。为什么会这样,当JavaFX是JRE不可或缺的一部分时 - 我不知道,但是你的问题应该通过安装OpenJFX包来解决:

# aptitude install openjfx  

(or using any other package manager), or by using Oracle's JRE.

(或使用任何其他包管理器),或使用Oracle的JRE。

#2


0  

A more efficient solution is to use Oracle JRE on Debians. I observed the same behavior when I built my JavaFX project using InteliJ Idea JavaFX Packager on Windows. Building a project with ordinary Maven did not cause this issue.

更有效的解决方案是在Debian上使用Oracle JRE。当我在Windows上使用InteliJ Idea JavaFX Packager构建我的JavaFX项目时,我观察到了相同的行为。使用普通Maven构建项目不会导致此问题。

#1


7  

Ubuntu, like Debian, has a separate package for OpenJFX (OpenJDK's implementation of JavaFX). Why this is the case, when JavaFX is an integral part of the JRE - I do not know, but your problem should be solved by installing the OpenJFX package:

像Debian一样,Ubuntu有一个单独的OpenJFX包(OpenJDK的JavaFX实现)。为什么会这样,当JavaFX是JRE不可或缺的一部分时 - 我不知道,但是你的问题应该通过安装OpenJFX包来解决:

# aptitude install openjfx  

(or using any other package manager), or by using Oracle's JRE.

(或使用任何其他包管理器),或使用Oracle的JRE。

#2


0  

A more efficient solution is to use Oracle JRE on Debians. I observed the same behavior when I built my JavaFX project using InteliJ Idea JavaFX Packager on Windows. Building a project with ordinary Maven did not cause this issue.

更有效的解决方案是在Debian上使用Oracle JRE。当我在Windows上使用InteliJ Idea JavaFX Packager构建我的JavaFX项目时,我观察到了相同的行为。使用普通Maven构建项目不会导致此问题。