英文:
I want a way to know all installed software in Windows using Java so I can run them from within a Java app
问题
我正在开发一个应用程序,用于在Windows环境中显示所有已安装的软件,包括那些来自Microsoft Store的以及用户从其他任何地方安装的软件,我希望用户能够直接从应用程序运行它们。是否有办法仅使用Java实现这一点?
我想要已安装应用程序的数据包括:应用程序名称、图标以及可执行应用程序的路径,以便我可以直接从Java应用程序运行它。
-
我知道如何使用Java打开应用程序。这不是我的问题。
-
通过“仅使用Java”,我的意思是不编写本地代码,但是使用一个使用本地代码的库没有问题。然而我并没有找到这样的库。
英文:
I'm developing an app that shows all installed software - including those from the Microsoft store, and surely any software the user installs from anywhere else - in Windows environment, and I want the user to be able to run them from the app directly. Is there anyway to achieve this using Java only ?
The data of the installed app I want : its name, its icon, and the path to the executable application so I can run it directly from the Java app.
-
I know how to open an app using Java. That's not what I'm asking for.
-
By "Java only" I mean without writing native code, but there is no problem to use a library that uses native code. Which I didn't find any
答案1
得分: 1
理论上是可能的。您应该能够遍历文件系统,检查每个文件名,并匹配文件后缀与Windows可执行文件扩展名之一相对应的名称。
实际上:
- 这可能需要很长时间。根据用户在计算机上拥有多少文件,可能需要很多分钟。如果他们挂载了远程文件系统,时间可能会更长。
- 匹配列表可能过长,不适合作为合理的选择列表。
- 没有办法知道任何特定应用程序的功能,以及如何调用它们。
上述假设执行此操作的Java应用程序是常规应用程序,而不是在Java安全沙箱中运行的WebStart应用程序、小程序或其他类型的应用程序。安全沙箱将禁止您的代码访问文件系统。
英文:
In theory, yes it is possible. You should be able to traverse the file system, examine each filename and match the names whose file suffix corresponds to one of the Windows executable file extensions.
In practice:
- It could take a long time to do that. Potentially many minutes, depending on how many files the user has on their machine. Even longer if they have remote file systems mounted.
- The list of matches is likely to be too long for a sensible pick list.
- There is no way of knowing what any particular application does, or how it should be invoked.
The above assumes that the Java app that does this is a regular app, not a webstart app or applet or something else that runs in a Java security sandbox. A security sandbox will forbid your code from accessing the file system.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论