我正在尝试在我的机器上创建文件夹的符号链接到其他m / c的共享驱动器
即如果我在D驱动器中有'test'文件夹。我想在共享文件夹上创建其符号链接,例如“\\ hjds22 \ Test”。当我尝试下面的代码时,它给了我java.nio.file.AccessDeniedException
。
代码如下:
Path newLink =Paths.get( "\\\\hjds22\\Test\\newLink");
Path target = Paths.get("D:\\test");
try {
Files.createSymbolicLink(newLink, target);
} catch (IOException x) {
System.err.println(x);
} catch (UnsupportedOperationException x) {
// Some file systems do not support symbolic links.
System.err.println(x);
}
注意:我在共享文件夹上有full rights
。我还在两个m / c上执行了fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1
。
答案 0 :(得分:0)
Runtime.getRuntime().exec("mklink /j dir target")
答案 1 :(得分:0)
Java不支持Windows快捷方式。
您必须使用外部库。例如jShortcut,它带有一个jni dll。
除了dll是32位dll之外,这非常好用。我(personaly)未能将其编译为64位。这将需要强制您的应用程序以32位jre运行。