FileUtils { public static void createSymbolicLink(final File source, final File target) throws IOException { System.out.println("[INFO] Creating symbolic link. Source:" + source.getAbsolutePath() + ", target: " + target.getAbsolutePath() + "."); mkdirs(target.getParentFile()); int returnValue = Forker.forkProcess(System.out, null, "ln", "-sf", source.getAbsolutePath(), target.getAbsolutePath()); if (returnValue != 0) { throw new RuntimeException("Cannot create symbolic link from '" + source + "' to '" + target + "'. Return value:" + returnValue); } }  static void mkdirs(final File f); static void deleteDirectory(final File directory); static String getDelta(File parent, File child); static String getRelativePath(String targetPath, String basePath, String pathSeparator); static boolean isSymbolicLink(File file); static void createSymbolicLink(final File source, final File target); static boolean isChild(File parent, File child); static String ensureLeadingSlash(final String path); static String getAppendix(final File f);  }
@Test public void testCreateSymbolicLink() throws Exception { File source = prepareFile(); File target = tmpFolder.newFile("target"); FileUtils.createSymbolicLink(source, target); Assert.assertTrue(checkForSymbolicLink(target)); }