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

JavaFX录屏项目出现module not found错误,已声明依赖

解决monte-screen-recorder模块找不到的问题

针对你遇到的java: module not found: monte.screen.recorder错误,按以下步骤排查:

1. 确认Maven依赖配置正确性

首先检查pom.xml中的依赖是否完全正确,当前有效的monte-screen-recorder依赖坐标为:

<dependency>
    <groupId>com.github.stephenc.monte</groupId>
    <artifactId>monte-screen-recorder</artifactId>
    <version>0.7.7.0</version>
</dependency>

执行mvn clean install重新拉取依赖,确保本地仓库中存在完整的JAR包。

2. 处理非模块化依赖的加载问题

monte-screen-recorder属于非模块化JAR(无内置module-info.class),它的自动模块名为monte.screen.recorder。若声明requires monte.screen.recorder;仍报错,需在编译和运行阶段强制添加模块:

  • 在Maven编译插件中配置VM参数:
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>11</source> <!-- 替换为你的Java版本 -->
                    <target>11</target>
                    <compilerArgs>
                        <arg>--add-modules</arg>
                        <arg>monte.screen.recorder</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
  • 运行时也需添加VM参数:--add-modules monte.screen.recorder

3. 调整module-info.java声明

如果是编译期检查报错,可尝试将声明改为:

requires static monte.screen.recorder;

static关键字表示该模块仅在编译期依赖,运行时通过自动模块机制加载。

4. 清理IDE缓存

若使用IntelliJ IDEA或Eclipse,执行以下操作消除缓存影响:

  • IntelliJ:File -> Invalidate Caches... -> Invalidate and Restart
  • Eclipse:Project -> Clean...,并重新导入Maven项目

5. 手动验证JAR模块属性

找到本地Maven仓库中的monte-screen-recorder-0.7.7.0.jar,解压后查看META-INF/MANIFEST.MF:

  • 若存在Automatic-Module-Name属性,直接使用该属性值作为模块名
  • 若不存在,自动模块名即为monte.screen.recorder(由文件名monte-screen-recorder转换而来)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 13:33:26