Kan*_*hka -1 java javafx ubuntu-22.04
我的申请代码
public class Main extends Application {
private static Scene scene;
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlloader = new FXMLLoader(LoginControler.class.getResource("loging.fxml"));
scene = new Scene(fxmlloader.load());
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用终端在 javafx 应用程序之上运行,但出现此错误。请告诉我我在脚本中是否犯了错误。我已经使用maven-shade-plugin来构建具有依赖项的 jar
root@abc-abc2051A:~# java -jar --module-path /opt/javafx-sdk-11/lib --add-modules javafx.controls myjar-1.0.0-shaded.jar
Error: Invalid or corrupt jarfile /opt/javafx-sdk-11/lib
Run Code Online (Sandbox Code Playgroud)
应用运行环境
的用法java是:
% java --help
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)
Run Code Online (Sandbox Code Playgroud)
即 jar 文件应立即跟随该-jar选项(其中应位于任何其他选项之后)。所以你需要
java --module-path /opt/javafx-sdk-11/lib --add-modules javafx.controls -jar myjar-1.0.0-shaded.jar
Run Code Online (Sandbox Code Playgroud)