简体   繁体   English

在Linux中运行时如何用Java创建符号链接?

[英]How to make a symlink in Java when running in Linux?

How to make a symlink in Java/JVM when running in Linux? 如何在Linux中运行时在Java / JVM中创建符号链接? Are there any other ways to this than using Java Native Interface (JNI) or java.lang.Runtime.exec("/bin/ln -s /some/path symlink") ? 除了使用Java Native Interface(JNI)java.lang.Runtime.exec("/bin/ln -s /some/path symlink")之外还有其他方法吗?

Creating a symlink is very platform dependant, but I mostly care about running on Linux, nice bonus would be if a shortcut would be created in Windows. 创建一个符号链接是非常依赖于平台的,但我最关心的是在Linux上运行,如果在Windows中创建一个快捷方式,那将是一个很好的奖励。

The JDK 7 includes (via NIO.2 ) a class called Files that provides a createSymbolicLink() method. JDK 7包含(通过NIO.2 )一个名为Files的类,它提供了createSymbolicLink()方法。

Previous versions don't provide any built-in way to produce that, so JNI or Runtime.exec() are your only real options. 以前的版本没有提供任何内置的方式来生成它,所以JNI或Runtime.exec()是你唯一真正的选择。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM