且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测某些软件是否安装在 Java 中的用户机器上

更新时间:2023-11-19 21:03:04

我不知道你的目标受众(用户),但失败时你可以提示用户输入路径(一个 FileChooserDialog)然后存储这个路径以备将来使用(如果没有再次抛出异常).前段时间我这样做了,幸运的是我的用户是系统管理员,所以他们可以在第一次发生错误时提供该信息(我还记录了如何在属性文件中更新或更改这些值).

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).

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

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