[英]How to resolve incubator module jdk.incubator.vector when running Java application
I am attempting to test the new Vector API introduced as an incubator module in JDK 16. For this, I have the following class:我正在尝试测试作为 JDK 16 中的孵化器模块引入的新 Vector API。为此,我有以下 class:
import jdk.incubator.vector.FloatVector;
import jdk.incubator.vector.VectorSpecies;
public class Main {
static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_256;
static void vectorComputation(float[] a, float[] b, float[] c) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
var m = SPECIES.indexInRange(i, a.length);
var va = FloatVector.fromArray(SPECIES, a, i, m);
var vb = FloatVector.fromArray(SPECIES, b, i, m);
var vc = va.mul(va).
add(vb.mul(vb)).
neg();
vc.intoArray(c, i, m);
}
}
public static void main(String[] args) {
float[] a = new float[]{1.0f, 3.0f, 2.0f};
float[] b = {1.0f, -1.0f, 5.0f};
float[] c = {1.0f, 6.0f, 1.0f};
Main.vectorComputation(a, b, c);
System.out.println(c);
}
}
I was able to compile this with the following command:我能够使用以下命令编译它:
javac Main.java --add-modules jdk.incubator.vector
However, when I try to run this I get the following error.但是,当我尝试运行它时,我收到以下错误。
java Main --add-modules jdk.incubator.vector
Error: Unable to initialize main class Main
Caused by: java.lang.NoClassDefFoundError: jdk/incubator/vector/Vector
How would I go about resolving this class?我将如何 go 解决这个 class?
Anything after the main class is interpreted as arguments to your application.主 class 之后的任何内容都被解释为您的应用程序的 arguments。 You need to rearrange the command to:
您需要将命令重新排列为:
java --add-modules jdk.incubator.vector Main
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.