Module javafx.base not found in Java 13

huangapple go评论77阅读模式
英文:

Module javafx.base not found in java 13

问题

我已经配置了JavaFX 11与OpenJDK 13。我已经将PATH_TO_FX静态地添加到JavaFX的位置。

Module javafx.base not found in Java 13

并且在项目结构中,我已经配置了OpenJDK 13,但仍然出现错误,提示在Java 11中未找到JavaFX基本模块

Module javafx.base not found in Java 13

英文:

I have configured javafx 11 with openjdk 13. I have added the PATH_TO_FX statically to the location of javafx.

Module javafx.base not found in Java 13

And in project structure I have configured openjdk 13 but still it is giving the error Module javafx.base not found in java 11

Module javafx.base not found in Java 13

答案1

得分: 2

每个集成开发环境(IDE)都可以处理Maven或Gradle项目。搜索"Maven repo openjfx",你会找到要添加的库依赖。由于可以预期会有许多模块和JAR文件,最好使用类似Maven这样的工具。搜索示例。

一个 pom.xml 文件可能包含以下OpenJFX依赖项。我已经为你复制了适用于你正在使用的Java 13的依赖项。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>junaid.muhammad</groupId>
    <artifactId>myjavafx</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>13</maven.compiler.source>
        <maven.compiler.target>13</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>13.0.2</version>
        </dependency>
        <!-- 其他 OpenJFX 依赖项 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <argLine>--illegal-access=permit</argLine>
                </configuration>
            </plugin>
            <plugin>
                <!-- 可能是 JavaFX 插件 -->
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <mainClass>.. MyApp</mainClass>
                </configuration>
            </plugin>    
        </plugins>
    </build>
</project>

希望你能看到优势:JavaFX 由多个模块组成。

英文:

Every IDE can do maven or gradle projects. Search for maven repo openjfx and you'll find the (library) dependency to add. As one can expect many modules, jars, better use such a tool as maven. Search examples.

A pom.xml might contain the following OpenJFX dependencies. I have copied them for java 13, which you are using too.

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;junaid.muhammad&lt;/groupId&gt;
    &lt;artifactId&gt;myjavafx&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;maven.compiler.source&gt;13&lt;/maven.compiler.source&gt;
        &lt;maven.compiler.target&gt;13&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-base&lt;/artifactId&gt;
            &lt;version&gt;13.0.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
            &lt;version&gt;13.0.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-graphics&lt;/artifactId&gt;
            &lt;version&gt;13.0.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-web&lt;/artifactId&gt;
            &lt;version&gt;13.0.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;junit&lt;/groupId&gt;
            &lt;artifactId&gt;junit&lt;/artifactId&gt;
            &lt;version&gt;4.13&lt;/version&gt;
            &lt;scope&gt;test&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.0.0-M5&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;argLine&gt;--illegal-access=permit&lt;/argLine&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
                &lt;!-- Maybe the JavaFX plugin --&gt;
                &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
                &lt;artifactId&gt;javafx-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;0.0.4&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;mainClass&gt;.. MyApp&lt;/mainClass&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;    
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;

I'll hope you see the advantage: there are several modules that make up JavaFX.

huangapple
  • 本文由 发表于 2020年9月17日 15:09:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63932959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定