You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下IntelliJ构建的Artifact无法运行问题求助

Hey there, let's troubleshoot why your JavaFX JAR won't run on Ubuntu 16.04. I've dealt with similar issues plenty of times, so let's break this down step by step:

First: Diagnose the Error via Command Line

Double-clicking a JAR hides critical error messages, which are key to figuring out what's wrong. Open a terminal, navigate to your JAR's folder with cd /path/to/your/jar/folder, then run:

java -jar your-app-filename.jar

Note the exact error output—this will point us directly to the root cause.

Common Issues & Fixes

1. Missing Executable Permissions

Ubuntu might block the JAR from running due to insufficient permissions. Fix this by running:

chmod +x your-app-filename.jar

Try double-clicking again, or re-run the command line command above.

2. Missing JavaFX Runtime Dependencies

Ubuntu 16.04's default OpenJRE (even version 9) often excludes JavaFX modules. Here's how to fix this:

  • Install the OpenJFX package via apt:
    sudo apt-get update && sudo apt-get install openjfx
    
  • If you're using a modular JavaFX app, you'll need to specify the module path when running. First, download the JavaFX SDK matching your JRE 9 version, then run:
    java --module-path /path/to/javafx-sdk-9/lib --add-modules javafx.controls,javafx.fxml -jar your-app-filename.jar
    
    Replace /path/to/javafx-sdk-9/lib with the actual path to your SDK's lib folder.

3. Incorrect Main Class Configuration in Artifact

Head back to IntelliJ's Project Structure > Artifacts and double-check:

  • You've selected the correct main class (the one that extends javafx.application.Application).
  • The generated META-INF/MANIFEST.MF file inside the JAR has the right entries. It should include:
    Main-Class: com.your.package.YourMainClass
    JavaFX-Main-Class: com.your.package.YourMainClass
    
    (Some JavaFX versions require both lines to launch properly.)

4. Incorrect JAR File Association in Ubuntu

Sometimes Ubuntu uses the wrong JRE to open JARs. Fix this:

  • Right-click your JAR file > Properties > Open With
  • Select your installed JRE 9's java executable (avoid generic "OpenJDK" entries if they lack JavaFX)
  • Check "Use this application to open all .jar files" and save.
Extra Tips
  • Try rebuilding your artifact from scratch in IntelliJ: Go to Build > Build Artifacts > Build to ensure no hidden build errors slipped through.
  • JRE 9 is pretty outdated—consider upgrading to JRE 11 or later (Ubuntu 16.04 supports these) for better JavaFX compatibility, since JavaFX became a separate module starting with JRE 11.

内容的提问来源于stack exchange,提问作者user1300214

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:47:52