Help (!) create shortcut on Windows from java code
I need something that creates symbolic link aka shortcut on Windows.
Code below creates symbolic link on Linux
<code>
Runtime.getRuntime().exec("ln -s <target> <link>");
</code>
Some windows installations can contain linkd.exe/shortcut.exe/xxxlink.exe but some don't.
I need something that will surely work on all. may be JNI and C/C++.

Comments
Did you consider java.nio.file.Path.createSymbolicLink?
I think this will work on Vista or above only.
probably it will work on all systems - but it requires Java 7. Anyway better than JNI
no, it works only on operation/filestore systems that support symbolic links. in other case :
Throws:
UnsupportedOperationException - if the implementation does not support symbolic links or the array contains an attribute that cannot be set atomically when creating the symbolic link
:o(
Symbolic link in Windows is introduced from Vista only. Old Shortcuts are not Symbolic links
really, as far as i understand, the difference between shortcut and symbolic link is that the shortcut is separated file but symbolic link .. just symbolic. shortcuts are very suitable for me. :o)
If you on Vista you have mklink.exe
http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-v...
i saw this or s-t similar. together with jshortcut this make sense. thanx.
this looks promising: http://alumnus.caltech.edu/~jimmc/jshortcut/
it looks very very promising. thanx. thanx to all. discussion temporarily can be closed.
interesting that this link appears second in google by query jni shortcut
i remember something about fox that jump over lazy dog or something similar..
Did you run it and got an exception? Because Windows 2000 already had support for symlinks: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
In another comment you said that shortcut is a file and symbolic link is not a file: that's wrong. Symbolic link is implemented by a file, too.
junctions are only for directories. they are created with linkd.exe command that yuri mentioned in the original post.
i looked at the jdk source code. for windows versions below vista it throws an exception.
You are right. I wanted to say the next :
"Symbolic links are automatically resolved by the file system. Any software programs, upon accessing a symbolic link, will see the target instead, whether the program is aware of symbolic links or not. On the other hand, shortcuts are treated like ordinary files by the files system and by software programs that are not aware of them. Only software programs that understand shortcuts (such as Windows) treat shortcuts as references to other files." read more
I still didn't try it, because i hope that issue can be resolved by changing PRD -- making full copy of target directory instead of using symbolic link.
Did you try "fsutil hardlink create NewFilename ExistingFilename" command ?
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs...