【问题标题】:stuck on javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module卡在 javafx.graphics 上不会将 com.sun.javafx.sg.prism 导出到未命名的模块
【发布时间】:2021-10-30 11:09:01
【问题描述】:

我已经被这个错误困扰了好几天了。我已经用谷歌搜索了它,并尝试了至少十几种不同形式的不同建议解决方案......

我的项目运行良好,直到我尝试使用一个名为 MonacoFX 的特定库,根据 GitHub 页面,该库是用 Java 13 开发的(我在这个项目中使用的是 Java 16.0.1)。该库的文档很简单,您可以像使用大多数库一样实例化该库,然后您只需使用它。但是,一旦我尝试实例化它,就会在运行时收到此错误:

Exception in thread "JavaFX Application Thread"
java.lang.IllegalAccessError: superclass access check failed:
  class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module @0x1937acaf)
        cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics) 
        because module javafx.graphics does not export 
        com.sun.javafx.sg.prism to unnamed module @0x1937acaf
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at eu.mihosoft.monacofx@0.0.7/eu.mihosoft.monacofx.MonacoFX.<init>(MonacoFX.java:49)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.data.GistFile.<init>(GistFile.java:28)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.data.GistObject.process(GistObject.java:113)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.data.GistObject.<init>(GistObject.java:27)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.github.GitHubApi.setGitHub(GitHubApi.java:31)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.ui.LoginWindowController.authenticate(LoginWindowController.java:39)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.ui.LoginWindow.lambda$new$1(LoginWindow.java:57)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8889)
at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3856)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1851)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)

看起来该库的开发人员已经有一段时间没有在该 GitHub 页面上活跃了,尽管我确实创建了一个问题。

我已经尝试了他们说使用命令行参数的解决方案,我的看起来像这样:

--module-path /Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk/Contents/Home/lib
--add-modules javafx.controls,javafx.fxml,javafx.web,javafx.graphics,javafx.media

我尝试过使用单独的 Launcher 类:

public class Launcher {
    public static void main(String[] args) {
        Main.main(args);
    }
}

没有任何效果,错误发生在我尝试实例化库的那一刻。

所以我正在寻找任何人可能对这个问题有的任何见解或知识......或者......如果有人知道提供语言感知代码样式编辑的优秀 JavaFX 库,我会对那个。

这是我的 POM 文件:

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dustinredmond</groupId>
    <artifactId>NewGistFX</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>NewGistFX</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.7.1</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>org.controlsfx</groupId>
            <artifactId>controlsfx</artifactId>
            <version>11.1.0</version>
        </dependency>
        <dependency>
            <groupId>net.synedra</groupId>
            <artifactId>validatorfx</artifactId>
            <version>0.1.13</version>
            <exclusions>
                <exclusion>
                    <groupId>org.openjfx</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.mylyn.github</groupId>
            <artifactId>org.eclipse.egit.github.core</artifactId>
            <version>2.1.5</version>
        </dependency>
        <dependency>
            <groupId>com.fifesoft</groupId>
            <artifactId>rsyntaxtextarea</artifactId>
            <version>3.1.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.dustinredmond.fxtrayicon</groupId>
            <artifactId>FXTrayIcon</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.kohsuke</groupId>
            <artifactId>github-api</artifactId>
            <version>1.133</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okio</groupId>
            <artifactId>okio</artifactId>
            <version>2.10.0</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>1.5.31</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-crypto</artifactId>
            <version>5.5.3</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.15</version>
        </dependency>
        <dependency>
            <groupId>eu.mihosoft.monacofx</groupId>
            <artifactId>monacofx</artifactId>
            <version>0.0.7</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>16</source>
                    <target>16</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.7</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.Main</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

这是我的模块信息文件:

module com.dustinredmond.newgistfx {
    requires javafx.controls;
    requires javafx.fxml;

    requires org.controlsfx.controls;
    requires validatorfx;
    requires javafx.graphics;

    requires java.prefs;
    requires org.apache.commons.codec;
    requires github.api;
    requires org.apache.commons.io;
    requires rsyntaxtextarea;
    requires java.desktop;
    requires FXTrayIcon;
    requires org.eclipse.egit.github.core;
    requires okhttp3;
    requires eu.mihosoft.monacofx;


    exports com.dustinredmond.newgistfx.ui;


    opens com.dustinredmond.newgistfx to javafx.base;
    opens com.dustinredmond.newgistfx.data to javafx.base;
}

感谢任何人提供的任何帮助。

谢谢

【问题讨论】:

    标签: java javafx java-module module-info


    【解决方案1】:

    如何调试依赖关系

    在您的项目中包含 maven 依赖插件。

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
            </plugin>
        </plugins>
    </build>
    

    在您的项目上运行 mvn dependency:tree

    [INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) @ NewGistFX ---
    [INFO] com.dustinredmond:NewGistFX:jar:1.0-SNAPSHOT
    [INFO] +- org.openjfx:javafx-controls:jar:16:compile
    [INFO] |  +- org.openjfx:javafx-controls:jar:win:16:compile
    [INFO] |  \- org.openjfx:javafx-graphics:jar:16:compile
    [INFO] |     \- org.openjfx:javafx-graphics:jar:win:16:compile
    [INFO] +- org.openjfx:javafx-fxml:jar:16:compile
    [INFO] |  \- org.openjfx:javafx-fxml:jar:win:16:compile
    [INFO] +- org.controlsfx:controlsfx:jar:11.1.0:compile
    [INFO] +- net.synedra:validatorfx:jar:0.1.13:compile
    [INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test
    [INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
    [INFO] |  +- org.opentest4j:opentest4j:jar:1.2.0:test
    [INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.7.1:test
    [INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.7.1:test
    [INFO] |  \- org.junit.platform:junit-platform-engine:jar:1.7.1:test
    [INFO] +- org.eclipse.mylyn.github:org.eclipse.egit.github.core:jar:2.1.5:compile
    [INFO] |  \- com.google.code.gson:gson:jar:2.2.2:compile
    [INFO] +- com.fifesoft:rsyntaxtextarea:jar:3.1.3:compile
    [INFO] +- junit:junit:jar:4.13.1:test
    [INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
    [INFO] +- com.dustinredmond.fxtrayicon:FXTrayIcon:jar:3.1.1:compile
    [INFO] +- org.kohsuke:github-api:jar:1.133:compile
    [INFO] |  +- org.apache.commons:commons-lang3:jar:3.9:compile
    [INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.5:compile
    [INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.5:compile
    [INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.12.5:compile
    [INFO] |  \- commons-io:commons-io:jar:2.8.0:compile
    [INFO] +- com.squareup.okio:okio:jar:2.10.0:compile
    [INFO] |  +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.20:compile
    [INFO] |  |  \- org.jetbrains:annotations:jar:13.0:compile
    [INFO] |  \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.20:compile
    [INFO] +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.5.31:compile
    [INFO] |  \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.5.31:compile
    [INFO] +- com.squareup.okhttp3:okhttp:jar:4.9.2:compile
    [INFO] +- org.springframework.security:spring-security-crypto:jar:5.5.3:compile
    [INFO] +- commons-codec:commons-codec:jar:1.15:compile
    [INFO] \- eu.mihosoft.monacofx:monacofx:jar:0.0.7:compile
    [INFO]    +- org.openjfx:javafx-base:jar:12.0.1:compile
    [INFO]    |  \- org.openjfx:javafx-base:jar:win:12.0.1:compile
    [INFO]    +- org.openjfx:javafx-web:jar:12.0.1:runtime
    [INFO]    |  \- org.openjfx:javafx-web:jar:win:12.0.1:runtime
    [INFO]    \- org.openjfx:javafx-media:jar:12.0.1:runtime
    [INFO]       \- org.openjfx:javafx-media:jar:win:12.0.1:runtime
    

    您的项目存在的问题以及如何解决这些问题

    请注意,您的项目使用的是 javafx-controls/javafx-graphics 16,而 monacofx 依赖于 javafx-base/javafx-web/javafx-media 12.0.1。

    JavaFX 不支持混合 JavaFX 模块版本,因此会中断。

    不要这样做。

    修复 pom.xml 中的版本控制,使所有 JavaFX 模块的版本相同。

    此外,您正在定义一个 module-info.java 文件,您需要将所需的依赖项添加到您的 module-info 以使其工作。所以修复它们(参见下面的示例,注意它需要 javafx.web 和 eu.mihosoft.monacofx)。

    不要通过启动器破解来创建 Launcher.java 文件。 JavaFX 的架构并非以这种方式运行,因此不受支持。

    如果您要从命令行运行,您需要指定您正在使用的所有模块的模块路径,而不仅仅是 JDK 模块。实际上,您不需要将 JDK 模块显式添加到模块路径中,它们会自动添加,因为它们是您正在使用的 jdk 映像的隐式一部分。

    您正在使用 Maven,因此要放置在模块路径上的所有必需的非 jdk 依赖项都在您的 Maven 存储库中,您可以从那里获取它们。如果您使用像 Idea 这样的 IDE 并设法让应用程序在 IDE 中运行(不使用 JavaFX maven 插件来运行它),那么查看 IDE 用于运行应用程序的命令行,特别是模块路径(或 -p) 选项,然后从那里复制所有内容,并在尝试从命令提示符运行时使用相同的内容。

    或者,使用 jlink/jdeps 和可能的 jpackage 创建一个适当的运行时映像(谷歌它),并使用它来执行您的应用程序。

    MonacoFX 没有 module-info.java 文件,因此在开发人员使用 module-info.java 文件创建新包之前,您将无法使用 jlink 来包含它。如果您愿意,您可以为项目提交功能请求,让他们这样做。

    也许还有另一个功能要求他们不需要 JavaFX 12 包作为依赖项

    例如,在 Maven 构建中,Monaco 项目中的这些依赖项可以标记为已提供,例如,Monaco 项目的文档可能会指出,为了使其工作,某些 JavaFX 模块必须位于模块路径上。

    示例应用程序

    这只是使用sample app from MonacoFX

    package com.example.monacotest;
    
    import eu.mihosoft.monacofx.MonacoFX;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    
    public class MonacoTestApp extends Application {
    
        public static void main(String[] args) {
            launch(args);
        }
    
        @Override
        public void start(Stage primaryStage) throws Exception {
            // create a new monaco editor node
            MonacoFX monacoFX = new MonacoFX();
            StackPane root = new StackPane(monacoFX);
    
            // set initial text
            monacoFX.getEditor().getDocument().setText(
                    """
                    #include <stdio.h>
                    int main() {
                       // printf() displays the string inside quotation
                       printf("Hello, World!");
                       return 0;
                    }
                    """
            );
    
            // use a predefined language like 'c'
            monacoFX.getEditor().setCurrentLanguage("c");
            monacoFX.getEditor().setCurrentTheme("vs-dark");
    
            // the usual scene & stage setup
            Scene scene = new Scene(root, 800,600);
            primaryStage.setTitle("MonacoFX Demo (running on JDK " + System.getProperty("java.version") + ")");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    }
    

    模块信息.java

    我只需要这些东西让摩纳哥为测试工作。您可以将所需的其余内容添加到项目中。

    必须要求javafx.web,否则您将收到问题中显示的错误。

    module com.example.monacotest {
        requires javafx.web;
        requires eu.mihosoft.monacofx;
    
        exports com.example.monacotest;
    }
    

    pom.xml

    我们排除了 monacofx 的 JavaFX 依赖项,并直接在我们的项目中为 JavaFX 定义所有必要的依赖项,使用正确的版本

    <?xml version="1.0" encoding="UTF-8"?>
    <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example.monacotest</groupId>
        <artifactId>MonacoTestApp</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <java.version>17</java.version>
            <javafx.version>17.0.1</javafx.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-web</artifactId>
                <version>${javafx.version}</version>
            </dependency>
            <dependency>
                <groupId>eu.mihosoft.monacofx</groupId>
                <artifactId>monacofx</artifactId>
                <version>0.0.7</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.openjfx</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    

    正确的依赖树:

    [INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) @ MonacoTestApp ---
    [INFO] com.example.monacotest:MonacoTestApp:jar:1.0-SNAPSHOT
    [INFO] +- org.openjfx:javafx-web:jar:17.0.1:compile
    [INFO] |  +- org.openjfx:javafx-web:jar:win:17.0.1:compile
    [INFO] |  +- org.openjfx:javafx-controls:jar:17.0.1:compile
    [INFO] |  |  +- org.openjfx:javafx-controls:jar:win:17.0.1:compile
    [INFO] |  |  \- org.openjfx:javafx-graphics:jar:17.0.1:compile
    [INFO] |  |     +- org.openjfx:javafx-graphics:jar:win:17.0.1:compile
    [INFO] |  |     \- org.openjfx:javafx-base:jar:17.0.1:compile
    [INFO] |  |        \- org.openjfx:javafx-base:jar:win:17.0.1:compile
    [INFO] |  \- org.openjfx:javafx-media:jar:17.0.1:compile
    [INFO] |     \- org.openjfx:javafx-media:jar:win:17.0.1:compile
    [INFO] \- eu.mihosoft.monacofx:monacofx:jar:0.0.7:compile
    

    【讨论】:

    • 请不要截图纯文本;)
    • 我需要找到一个很好的资源来教育自己使用 Java 进行模块化编程。直到最近,我几乎一直在使用 Java8,这种模块化的变化真的让我陷入了困境。
    • @MichaelSims 这是一篇很好的模块介绍文章:Understanding Java 9 Modules
    • 另外,我根据您的回答对我的项目进行了以下更改,这就是修复它的原因:我将 SDK 更改为 17.0.1,我将 POM 文件更改为使用 ${javafx .version} 在那些适用的依赖项上,我在模块信息中添加了需要 javafx.web 并且我从 IntelliJ 中的运行/编辑配置中完全删除了所有命令行参数,现在项目运行完美。我将阅读您评论的文章,​​并了解目前对我来说关于模块化编码和更新的 Java 版本的谜团。非常感谢您如此详细的回复。
    • 嗯,我阅读了你评论的关于模块解释的链接,我发现自己对很多事情感到很困惑。我想也许最让我困惑的是,在试图理解这种用 Java 编写代码的新方法时,我什至不知道目前要问什么问题。我认为可能有许多基本概念——可能是一般的 OOP 或者可能只是 Java——我根本不知道,也许我不需要知道,因为像 IntelliJ 这样的 IDE 掩盖了需要知道的方式——在至少这是我目前的假设。
    猜你喜欢
    • 2020-04-24
    • 2019-04-01
    • 2021-09-20
    • 2019-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多