所以我下载了 JDK 15 - OpenJDK 。
在Intellij中运行以下代码
import jdk.incubator.foreign.MemorySegment; //The problem seems to occur here in this import
public class Application {
public static void main(String[] args){
MemorySegment m = MemorySegment.allocateNative(400L);
}
}
在 intelliJ 中,我转到文件 -> 项目结构 -> 项目 SDK -> 选择 15
在应用程序配置(Intellij运行项目)中,我声明了JRE 15(java版本15.0.2)
我收到以下错误
C:\Users\repositories\java15project\src\main\untitled\src\Application.java:2:21
java: package jdk.incubator.foreign is not visible
(package jdk.incubator.foreign is declared in module jdk.incubator.foreign, which is not in the module graph)
有人可以帮我吗?
使用选项运行--add-modules jdk.incubator.foreign
或者,创建一个module-info.java
文件,例如像这样:
module my.module.name.here {
requires jdk.incubator.foreign;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)