在Linux中运行时如何用Java创建符号链接? [英] How to make a symlink in Java when running in Linux?
问题描述
如何在Linux中运行时在Java / JVM中创建符号链接?除了使用 Java Native Interface(JNI)或 java.lang.Runtime.exec(/ bin / ln -s / some / path symlink)
?
How to make a symlink in Java/JVM when running in Linux? Are there any other ways to this than using Java Native Interface (JNI) or java.lang.Runtime.exec("/bin/ln -s /some/path symlink")
?
创建符号链接是非常依赖平台,但我最关心的是在Linux上运行,如果在Windows中创建一个快捷方式,那将是一个很好的奖励。
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.
推荐答案
JDK 7 包括(通过 NIO.2 )一个名为 文件
提供 createSymbolicLink()
方法。
The JDK 7 includes (via NIO.2) a class called Files
that provides a createSymbolicLink()
method.
以前的版本没有提供任何内置方式来生成它,所以JNI或 Runtime.exec()
是你唯一真正的选择。
Previous versions don't provide any built-in way to produce that, so JNI or Runtime.exec()
are your only real options.
这篇关于在Linux中运行时如何用Java创建符号链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!