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

Mooc.fi第13章GUI开发:JavaFX配置失败求助

Mooc.fi第13章JavaFX运行问题求助

在学习Mooc.fi第13章《图形用户界面》的“我的第一个应用”时,JavaFX始终无法正常运行,导致学习停滞。

已尝试以下方案但均未解决:

  • 下载JavaFX SDK并按相关教程配置项目
  • 参考多个论坛讨论中的解决方案调整配置

项目POM文件的依赖与插件部分:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>fi.helsinki.cs.tmc</groupId>
        <artifactId>edu-test-utils</artifactId>
        <version>0.4.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testfx</groupId>
        <artifactId>testfx-junit</artifactId>
        <version>4.0.15-alpha</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testfx</groupId>
        <artifactId>testfx-core</artifactId>
        <version>4.0.15-alpha</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testfx</groupId>
        <artifactId>openjfx-monocle</artifactId>
        <version>8u76-b04</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
            <configuration>
                <argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
            </configuration>
        </plugin>
        <plugin>
            <groupId>fi.helsinki.cs.tmc</groupId>
            <artifactId>runner-maven-plugin</artifactId>
            <version>1.0.1</version>
        </plugin>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.3</version>
            <configuration>
                <release>${maven.compiler.release}</release>
                <launcher>launcher</launcher>
                <mainClass>myFirstApplication.MyFirstApplication</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

运行测试时的错误信息:

RuntimeException: No toolkit found
No toolkit found
com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
com.sun.javafx.application.PlatformImpl.isFxApplicationThread(PlatformImpl.java:401)
javafx.application.Platform.isFxApplicationThread(Platform.java:182)

已尝试其他同问题用户的解决方案,但问题依旧,恳请提供正确的配置指导或解决思路。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 03:34:52