Check if a program is installed on a linux machine from a java applet

你说的曾经没有我的故事 提交于 2019-12-24 06:04:44

问题


Hi I need to be able to check if a certain software is installed on the clients computer and where, in order to launch it. I found the following three posts as to how to do so on Windows and Mac but I can't seem to figure it out for Linux as there is no registry. Does any one know how this can be done on Linux?

Similar posts for Windows and Mac:
Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction?
read/write to Windows Registry using Java
How can I see the software installed in a Mac OS using a java application?

any help would be greatly appreciated :)


回答1:


Assuming your security context allows it, you could call out to which.

$ which java
/usr/bin/java

which will output nothing if the program is not found.




回答2:


Use the

which file

command to find out if the software is installed in the path. If that comes up with nothing then you could do a

find ./ -name "file"

Also check their local bin or .bin if its not included in the path.




回答3:


Well, basically every binary installed on Linux is in the PATH (environment variable), so if you can find it there, it's there.

There may also be software that installs into other paths, but in this case the user would need to point them out. It is a very uncommon case to have an application in a seperate path and not adding that one to PATH.



来源:https://stackoverflow.com/questions/5870398/check-if-a-program-is-installed-on-a-linux-machine-from-a-java-applet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!