I have installed Oracle Java on my Ubuntu 16.04. I tried making a hard link:
ln /usr/local/jdk-9.0.1/bin/java /usr/bin/java
When I ran java I got this error:
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
I removed the hard link and made a soft link instead:
ln -s /usr/local/jdk-9.0.1/bin/java /usr/bin/java
That solves the problem. So why does the soft link work while the hard one failed?
When you create a symbolic link
ln -s
to a file it acts like a link from Windows world. You can launch this symlink from any folder but the working directory will be the one where the original file is located.As for hard links, when you create a hard link
ln
you make a sort of a copy of the original file preserving all its properties (it has the same inode as the original file). Thus the working directory will be the one where the hard link is located. So in your case, the hard link works fine but it uses/usr/bin
as its working dir & looks for other supplementary files in this folder.