import java.nio.file.Files; import java.nio.file.Paths; import java.io.IOException; public class Test { public static void main(String[] args) throws IOException { java.nio.file.Files.createDirectories(Paths.get("/tmp/emptyDirectory")); java.nio.file.Files.createSymbolicLink(Paths.get("/tmp/symlink"), Paths.get("/tmp/emptyDirectory")); // following line errors, but should work java.nio.file.Files.createDirectories(Paths.get("/tmp/symlink")); } }