Detect if certain software is installed on a user's machine in Java

后端 未结 4 1292
时光说笑
时光说笑 2020-12-20 00:53

I have a Java application which requires certain software (one of them being Perl) before it can be run. What I used to do to detect for Perl is:

Runtime.get         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 01:36

    These kind of questions seem to be popping out every now and then and the answer (almost) always is no. Most general reason for the negative answer is that Java is run in a homogenous Virtual Machine environment which is by design the same on all platforms; Those operations you can't abstract away/do reliably on at least the most supported platforms just can't be done easily. Detecting external events in the OS in general such as which non-Java applications are also run/installed falls into that "not easy to do" category.

    Certainly there could be need/market for JNI libraries for the purpose but those steer heavily from the cross-platform requirement these questions always seem to want to and that's why the short answer is "no". As far as I can see, what you're doing currently is the cleanest way to detect Perl unless you're willing to include perljvm or similar in your project.

提交回复
热议问题