简体   繁体   English

java: package jdk.incubator.foreign is not visible 错误在 Java 15

[英]java: package jdk.incubator.foreign is not visible error in Java 15

So I have downloaded JDK 15 - OpenJDK.所以我已经下载了 JDK 15 - OpenJDK。

Running in Intelij the following code在 Intelij 中运行以下代码

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);

   }

 }

In inteliJ I have gone to File -> Project Structure -> Project SDK -> selected 15在 inteliJ 我已经转到文件 -> 项目结构 -> 项目 SDK -> 选择 15

In Application configurations (Intelij run project) I have declared JRE 15 (java version 15.0.2)在应用程序配置(Intelij 运行项目)中,我声明了 JRE 15(java 版本 15.0.2)

I receive the following error我收到以下错误

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)

Could someone please help me?有人可以帮我吗?

Run with option --add-modules jdk.incubator.foreign使用选项--add-modules jdk.incubator.foreign运行

Alternatively, create a module-info.java file, eg like this:或者,创建一个module-info.java文件,例如像这样:

module my.module.name.here {
    requires jdk.incubator.foreign;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java:ByteBuffer 与 jdk.incubator.foreign(巴拿马)的性能 国外 Memory 方法(MemoryLayout/Segment) - Java: Performance of ByteBuffer versus jdk.incubator.foreign (Panama) Foreign Memory methods (MemoryLayout/Segment) Java 9 HttpClient java.lang.NoClassDefFoundError:jdk / incubator / http / HttpClient - Java 9 HttpClient java.lang.NoClassDefFoundError: jdk/incubator/http/HttpClient Java11中找不到jdk.incubator.httpclient模块 - The jdk.incubator.httpclient module not found in Java11 运行 Java 应用程序时如何解析孵化器模块 jdk.incubator.vector - How to resolve incubator module jdk.incubator.vector when running Java application 如何在 Java 16 中将 UUID 转换为 jdk.incubator.vector.Vector,反之亦然 - How to convert UUID into jdk.incubator.vector.Vector and vice versa in Java 16 使模块jdk.incubator.httpclient在运行时可见 - Making the module jdk.incubator.httpclient visible at runtime 没有可用的软件包Java JDK - Yum No Package available Java JDK JDK9上的“包java.net.http不存在”错误 - "package java.net.http does not exist" error on JDK9 jdk.dynalink在Java 9中的bootclasspath中不可见 - jdk.dynalink not visible from bootclasspath in Java 9 在Java9中将孵化器Http类与Maven结合使用 - Using Incubator Http Classes with Maven in Java9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM