简体   繁体   English

如何获取当前选择的已安装JRE的位置?

[英]How to get location of currently selected Installed JRE?

As you know in Eclipse there is a way to specify the preferred JRE to use (Windows | Preferences | Java | Installed JREs). 如您在Eclipse中所知,有一种方法可以指定要使用的首选JRE(Windows |首选项| Java |已安装的JRE)。 So I need to get the location of currently selected JRE as a preferred. 因此,我需要获取当前选择的JRE的位置作为首选位置。 How can I do that? 我怎样才能做到这一点? The similar questions on this site are with no proper answers and it is not seams easy to find what I need in Eclipse forums. 这个站点上的类似问题没有正确的答案,在Eclipse论坛中很难找到所需的东西。

I'm developing plugin for Eclipse and, I guess, there should be specific set of APIs to work with Eclipse preferences but can not figure out how to find it. 我正在为Eclipse开发插件,我想应该有一组特定的API与Eclipse首选项一起使用,但无法弄清楚如何找到它。

Update: I need to get the location programmatically, from my own plugin. 更新:我需要以编程方式从我自己的插件中获取位置。 And it should work for Windows and Linux. 它应该适用于Windows和Linux。

Take a look at this registry key (on Windows): 看一下此注册表项(在Windows上):

HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment HKEY_LOCAL_MACHINE \\ SOFTWARE \\ JavaSoft \\ Java运行时环境

You can use RegOpenKey() and RegQueryValueEx() to query the key/value you need. 您可以使用RegOpenKey()RegQueryValueEx()来查询所需的键/值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM