如何在IntelliJ中配置jFoenix?配置后无法运行问题求助
It sounds so frustrating that you’ve got jFoenix working smoothly in Scene Builder 8.0.5 but can’t get it running in IntelliJ—even after trying JAR imports and Maven dependencies, and seeing the IDE recognize the library. Let’s walk through targeted fixes that might resolve this:
1. Validate Maven Dependency Configuration (If Using Maven)
Double-check your pom.xml to ensure the jFoenix dependency doesn’t have a provided scope (which excludes it from the runtime classpath). For JavaFX 8 (your version is 8.0.171), use a compatible jFoenix release like this:
<dependency> <groupId>com.jfoenix</groupId> <artifactId>jfoenix</artifactId> <version>8.0.10</version> <!-- Matches JavaFX 8 compatibility --> </dependency>
2. Confirm Library is Added to the Module Path
If you’re using a newer Java version but targeting JavaFX 8, jFoenix needs to be on the module path (not just the classpath):
- Go to
File > Project Structure > Modules > Dependencies - Click the
+button, selectJARs or directories - Locate your jFoenix JAR, and choose
Module pathwhen prompted
3. Fix Runtime Configuration Classpath
Sometimes IntelliJ doesn’t automatically include jFoenix in the runtime setup:
- Navigate to
Run > Edit Configurations - Select your JavaFX application configuration
- Under the
Classpathtab, verify jFoenix is listed inUser entries. If not, click+and add it manually.
4. Clean and Rebuild Your Project
Corrupted build artifacts can cause unexpected runtime failures:
- Run
Build > Clean Project - Follow with
Build > Rebuild Project - Restart IntelliJ to clear any cached data that might be interfering
5. Check Console for Specific Error Messages
When your program fails to run, look at the console output for errors like ClassNotFoundException for jFoenix controls. This will directly tell you if the library isn’t being loaded at runtime (the most common root cause here).
6. Match jFoenix Versions Across Tools
Ensure the jFoenix version you’re using in IntelliJ matches the one in Scene Builder. Mismatched versions can lead to subtle runtime conflicts even if Scene Builder works.
Your FXML Code Reference
Just to confirm, your FXML imports and control usage look correct for jFoenix:
<?xml version="1.0" encoding="UTF-8"?> <?import com.jfoenix.controls.JFXButton?> <?import com.jfoenix.controls.JFXPasswordField?> <?import com.jfoenix.controls.JFXTextField?> <?import javafx.scene.control.Label?> <?import javafx.scene.effect.Bloom?> <?import javafx.scene.effect.InnerShadow?> <?import javafx.scene.image.Image?> <?import javafx.scene.image.ImageView?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.text.Font?> <AnchorPane prefHeight="576.0" prefWidth="1050.0" style="-fx-background-color: #20120F;" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.SignInController"> <children> <AnchorPane layoutX="639.0" layoutY="88.0" prefHeight="400.0" prefWidth="350.0" style="-fx-background-color: #9C2B27;"> <children> <JFXTextField focusColor="#d4af37" layoutX="50.0" layoutY="135.0" prefWidth="250.0" promptText="Username / E-mail" unFocusColor="#c3b7b7" /> <JFXPasswordField focusColor="#d4af37" layoutX="50.0" layoutY="222.0" prefWidth="250.0" promptText="Password" unFocusColor="#c3b7b7" /> <JFXButton layoutX="50.0" layoutY="312.0" prefWidth="250.0" style="-fx-background-color: #E45652;" text="Sign In" textFill="#dad6d6"> <effect> <Bloom threshold="0.0" /> </effect> <font> <Font name="System Bold" size="12.0" /> </font> </JFXButton> <Label layoutX="122.0" layoutY="52.0" text="Sign In" textFill="WHITE"> <font> <Font name="Cambria" size="36.0" /> </font> <effect> <InnerShadow /> </effect> </Label> </children> </AnchorPane> <ImageView fitHeight="576.0" fitWidth="576.0" opacity="0.2" pickOnBounds="true" preserveRatio="true"> <image> <Image url="@../../Image/TG_Background.jpg" /> </image> </ImageView> <Label layoutX="55.0" layoutY="131.0" text="Don't Have An Account? No Problem Sign Up Now And Enjoy Our Variety Of Features" textAlignment="CENTER" textFill="WHITE"> <font> <Font name="Cambria" size="30.0" /> </font> <effect> <Bloom threshold="0.0" /> </effect> </Label> <JFXButton layoutX="212.0" layoutY="266.0" prefHeight="44.0" prefWidth="153.0" style="-fx-background-color: #E45652;" text="Sign Up" textFill="#dad6d6"> <effect> <Bloom threshold="0.0" /> </effect> <font> <Font name="System Bold" size="18.0" /> </font> </JFXButton> </children> </AnchorPane>
Start with checking the console for specific error messages—they’re the best clue to pinpointing exactly what’s going wrong. Let me know if any of these steps get your jFoenix controls running in IntelliJ!
内容的提问来源于stack exchange,提问作者Mohamad S.

