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

无法正确连接JavaFX组件,启动参数报错如何解决?

Fixing the "Unrecognised option" Error with JavaFX Module Configuration

Hey there, let's get this JavaFX connection issue sorted out! That error message you're seeing is a dead giveaway about what's going wrong with your module path setup.

What's Causing the Error?

Your VM arguments are formatted incorrectly—you've merged multiple options together without proper spacing, so the JVM can't parse them as separate valid commands. Looking at your error:

Unrecognised option :--module-pathD:\javafx-sdk-11.0.2\lib--add-modules=javafx.controls

You can see that --module-path is stuck directly to your SDK path, and that whole chunk is merged with --add-modules=javafx.controls—no spaces anywhere to tell the JVM where one option ends and the next begins.

Correct Configuration Steps

1. Proper Command Line Argument Format

If you're running your app via the command line, use this corrected format for your VM arguments:

--module-path "D:\javafx-sdk-11.0.2\lib" --add-modules javafx.controls

Key fixes here:

  • Added a space between --module-path and the SDK library path
  • Wrapped the path in quotes (a good practice even if your path has no spaces, to avoid unexpected issues)
  • Separated --module-path and --add-modules with a space
  • Note: The = sign in --add-modules is optional—both --add-modules javafx.controls and --add-modules=javafx.controls work, but spacing is mandatory.

2. IDE Configuration (e.g., IntelliJ IDEA)

If you're using an IDE to run your project, update your run configuration:

  • Go to Run > Edit Configurations
  • Select your application's run configuration from the list
  • In the VM options field, paste the corrected arguments above
  • Double-check the SDK path to ensure it points to the correct lib folder of your JavaFX 11.0.2 installation
  • Click Apply and run your app again

Quick Additional Checks

  • Verify that D:\javafx-sdk-11.0.2\lib actually exists and contains all the JavaFX .jar files (like javafx.controls.jar)
  • Make sure you're using a JDK version compatible with JavaFX 11—this requires JDK 11 or later, since JavaFX became a separate modular library starting with version 11.

内容的提问来源于stack exchange,提问作者224_54Yash Agrawal

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 12:27:50