Currently I use \'ln
\' command via Runtime.exec()
. It works fine. The only problem is that in order to do this fork, we need twice the heap space o
The answer can be read in Oracle The Java™ Tutorials Links, Symbolic or Otherwise
You could use Windows instead of UNIX? ;) I believe JDK7 will be using a call similar to CreateProcess instead of fork where available.
A more practical solution would be to create a new child process soon after starting. If you are using a 10g heap, another small Java process probably wont be so bad. Get that process (via use of streams) to exec.
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"));
you could try JNA in place of JNI (JNA has some clear advantages over JNI); yes, check the JSR 203