如果我运行命令jar --create --release 9 -C com.java.mrjar.nine\build\classes .
我有错误
entry: META-INF/versions/9/com/java/mrjar/nine/Main.class, contains a new public class not found in base entries
entry: META-INF/versions/9/com/java/mrjar/nine/TimeUt.class, contains a new public class not found in base entries
invalid multi-release jar file mrjars\com.java.mrjar.jar deleted
这些是 Main 和 TimeUt 类:
package com.java.mrjar.nine;
import java.time.Instant;
public class Main {
public static void main(String[] args) {
System.out.println("Inside jdk9 Main.main()...");
TimeUt t = new TimeUt();
System.out.println("Local Date: "+t.getLocalDate(Instant.now()));
}
}
package com.java.mrjar.nine;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
public class TimeUt {
public TimeUt() {
System.out.println("creating jdk9 version of TimeUt");
}
public LocalDate getLocalDate(Instant now){
return LocalDate.ofInstant(now, ZoneId.systemDefault());
}
}
我可以在不添加--release 9的情况下正常创建jar,但它是一个普通的 jar,它没有version>9数据。