检测是否在Java中的用户计算机上安装了某些软件 [英] Detect if certain software is installed on a user's machine in Java

查看:548
本文介绍了检测是否在Java中的用户计算机上安装了某些软件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java应用程序,它需要某些软件(其中一个是Perl)才能运行。我以前用来检测Perl的是:

  Runtime.getRuntime()。exec(perl Test.pl) ; 

如果有IOException声明没有Perl。



然而,我的一位用户抱怨该应用程序一直失败,因为他没有将Perl放入他的路径变量中。所以这就是为什么我要问:是否有任何跨操作系统的方法来检测Perl(或任何其他软件)是否安装在用户的系统和程序的路径上?

解决方案

我不知道您的目标受众(用户),但失败后您可以提示用户输入路径(FileChooserDialog),然后存储此路径以备将来使用用法(如果不再抛出异常)。我之前做过那个,幸运的是我有用户是SysAdmins,所以当第一次发生错误时他们可以提供这些信息(我还记录了如何在属性文件中更新或更改这些值)。 / p>

Don提到的其他选项是安装相对于您的安装所需的软件,这是一个更常见的选项。


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.getRuntime().exec("perl Test.pl");

and if there was an IOException declare that there was no Perl.

However, one of my users complained that the app kept failing because he had not placed Perl in his path varible. So this is why I'm asking: Is there any cross-operating system way to detect whether Perl (or any other software) is installed on the user's system and the path to the program?

解决方案

I don't know your target audience (users), but upon failure you could prompt the user to enter the path (a FileChooserDialog) and then store this path for future usage (if the exception is not thrown again). I did that some time ago, luckily I had users that were SysAdmins, so it was OK for them to provide that info when the error happened the first time (I also documented how to update or change these values in a properties file).

Other option as mentioned by Don, is to install the required software as relative to your installation, that's a more common option.

这篇关于检测是否在Java中的用户计算机上安装了某些软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆