JavaFX: Could not find or load main class only on

2019-01-25 10:27发布

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).

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

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:

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

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-25 11:07

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:

# aptitude install openjfx  

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

查看更多
聊天终结者
3楼-- · 2019-01-25 11:18

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.

查看更多
登录 后发表回答