title: How to force Java 7 to create "directory symlinks" on Windows instead of "file symlinks"?
body: <p>I'm using Oracle Java 7 on Windows 64 bit.</p>
  
  <p>When I create a symlink using <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html" rel="nofollow">Files.createSymbolicLink</a>, I notice this behavior:</p>
  
  <ol>
  <li>If the target is a directory, a "directory symlink" is created.</li>
  <li>If the target is a file, a "file symlink" is created.</li>
  <li>If the target does not exist, a "file symlink" is created.</li>
  </ol>
  
  <p><a href="http://www.quora.com/File-Systems/What-are-essential-differences-in-the-implementation-of-Symbolic-Links-between-Windows-and-Linux" rel="nofollow">The type of the symlink is fixed and never changes</a>, regardless of any changes to its target.</p>
  
  <p>Using Windows' native <code>mklink</code> command, it is possible to force the link type to be a "directory symlink". Is it possible to achieve this using the native Java API or some library?</p>
  
  <p>One trivial and ugly way is:</p>
  
  <ol>
  <li>If the target is a directory, just create the link</li>
  <li>If the target doesn't exist, create a new empty target directory, create the link, and delete the directory.</li>
  <li>If the target is a file ... handle it (move it, apply #2, move it back).</li>
  </ol>
  
  <p>Fugly.</p>