Creating a Hard Link in java
you could try JNA in place of JNI (JNA has some clear advantages over JNI); yes, check the JSR 203
This is very easy with JNA:
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary)
Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),
CLibrary.class);
int link(String fromFile, String toFile);
}
public static void main(String[] args) {
CLibrary.INSTANCE.link(args[0], args[1]);
}
Compile and run!
It’s easy in Java 7 using createLink:
Files.createLink(Paths.get("newlink"), Paths.get("existing"));