在Intelij中使用Glisten Afterburner创建Gluon项目失败及启动异常
Hey there, let's troubleshoot the issues you're facing with your Glisten Afterburner + Gluon Mobile app in IntelliJ. Since you mentioned the FXML is default-generated, the problem is likely tied to dependency mismatches, Scene Builder configuration, or IntelliJ run setup. Here are the most common fixes:
Gluon projects rely on strict version compatibility between Gluon Mobile (Charm) and Glisten Afterburner. If your dependencies are out of sync, you'll get runtime errors or missing class issues.
- Open your
build.gradle(orpom.xmlif using Maven) and ensure you're using compatible versions. For example, as of now, a working combination is:dependencies { implementation 'com.gluonhq:charm:6.2.0' implementation 'com.gluonhq:glisten-afterburner:2.0.1' } - Force a dependency refresh in IntelliJ: Click the "Sync Project with Gradle Files" button in the top-right corner, or run this command in your terminal:
./gradlew clean build --refresh-dependencies
Scene Builder doesn't automatically recognize Gluon's custom controls unless you add the Charm library to its classpath:
- Open Scene Builder
- Go to
Library > Import JAR/FXML File - Navigate to your local Maven/Gradle repository (e.g.,
~/.m2/repository/com/gluonhq/charm/6.2.0/charm-6.2.0.jar) and select the Charm JAR - After importing, Scene Builder will load Gluon's controls, and your default FXML files should open without errors.
Sometimes IntelliJ's auto-generated run config misses critical VM parameters or points to the wrong main class:
- Go to
Run > Edit Configurations - Ensure your main class is the one extending
MobileApplication(e.g.,com.yourpackage.Main) - Instead of running the main class directly, try using Gradle's built-in run task: Open the Gradle panel in IntelliJ, navigate to
Tasks > application > run, and click to execute. This ensures all Gluon-specific setup (like JavaFX module paths) is handled correctly.
If you still hit errors, look for specific hints in the stack trace:
ClassNotFoundException: Means a dependency isn't being pulled in—double-check your build file and sync status.- FXML load errors: Ensure your FXML has the correct namespaces (default generated files should already have this, but verify):
The namespace version should match your JavaFX version (Gluon Mobile 6.x uses JavaFX 17).<View xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.yourpackage.PrimaryPresenter">
Give these steps a shot—most people resolve this by fixing dependency sync or Scene Builder library setup.
内容的提问来源于stack exchange,提问作者João Marques

