java检测电脑中的所有文件,检测是否在Java中的用户计算机上安装了某些软件

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值