我正在尝试使用Netbeans构建的两个项目在Windows 10中创建一个多版本jar。项目是相同的,唯一的区别是一个有jdk8属性>源/库和另一个有jdk9。 它们都有一个 com.jdojo.mrjar 包,在它下面都有一个TimeUtil类
public class TimeUtil {
public TimeUtil() {
System.out.println("Creating JDK 8 version of TimeUtil...");
}
public LocalDate getLocalDate(Instant now){
return now.atZone(ZoneId.systemDefault()).toLocalDate();
}
}
一个简单的主类叫它
public class Main {
public static void main (String[] args) {
System.out.println("Inside JDK 8 version of Main.main([])...");
TimeUtil t = new TimeUtil();
LocalDate ld = t.getLocalDate(Instant.now());
System.out.println("Local Date: "+ld);
}
}
jdk9版本还有一个module-info.java
:
module com.jdojo.mrjar {
exports com.jdojo.mrjar;
}
他们都编译并正常运行,但是当我尝试命令时 jar --create --file mrjars \ com.jdojo.mrjar.jar -C com.jdojo.mrjar.jdk8 \ build \ classes。 --release 9 -C com.jdojo.mrjar.jdk9 \ build \ classes。我有以下错误:
Warning: entry META-INF/versions/9/.netbeans_automatic_build contains a class that
is identical to an entry already in the jar
Warning: entry META-INF/versions/9/.netbeans_update_resources contains a class that
is identical to an entry already in the jar
java.nio.file.NoSuchFileException: C:\Users\Talon\AppData\Local\Temp\com.jdojo.mrjar.jar15612736007782051855.jar -> mrjars\com.jdojo.mrjar.jar
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:384)
at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:288)
at java.base/java.nio.file.Files.move(Files.java:1413)
at jdk.jartool/sun.tools.jar.Main.validateAndClose(Main.java:460)
at jdk.jartool/sun.tools.jar.Main.run(Main.java:343)
at jdk.jartool/sun.tools.jar.Main.main(Main.java:1670)
截至How to create multi-release jar and filtering input content?,如果我尝试建议的解决方案,我有
$(find : no such file or directory
-name : no such file or directory
*.class) : no such file or directory
所以我只是从文件夹中删除了.netbeans_automatic_build
和.netbeans_update_resources
文件,因为它们似乎是问题的原因,如果我现在尝试命令我有不同的错误
java.nio.file.NoSuchFileException: C:\Users\Talon\AppData\Local\Temp\com.jdojo.mrjar.jar12504656669179695067.jar -> mrjars\com.jdojo.mrjar.jar
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:384)
at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:288)
at java.base/java.nio.file.Files.move(Files.java:1413)
at jdk.jartool/sun.tools.jar.Main.validateAndClose(Main.java:460)
at jdk.jartool/sun.tools.jar.Main.run(Main.java:343)
at jdk.jartool/sun.tools.jar.Main.main(Main.java:1670)
我已经检查了该文件夹,并且com.jdojo.mrjar.jar12504656669179695067.jar
不存在,问题是为什么它应该是?