Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Hard Link in java

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 of the application. My app is a 64 bit app with heap size around 10Gigs and thus its runs out of swap space. I couldn't find any configuration that could fix this.

I also want not to use JNI for the same. Also I had heard somewhere that this facility will soon be provided in java 7.

like image 506
baskin Avatar asked Apr 23 '09 19:04

baskin


1 Answers

It’s easy in Java 7 using createLink:

Files.createLink(Paths.get("newlink"), Paths.get("existing"));
like image 184
Benedikt Waldvogel Avatar answered Sep 29 '22 01:09

Benedikt Waldvogel