使用eclipse API读取eclipse安装路径
我打开了eclipse 3.3.2。 现在我需要获取当前的 eclispe 安装路径。 有
没有eclipse API可以获取eclipse安装路径? 请在这方面提供帮助。
提前致谢..
斯内哈尔
I opened eclipse 3.3.2. Now i need to get the current eclispe installation path. Is
there any eclipse API to get the eclipse installation path? Please help in this regard.
Thanks in Advance..
Snehal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 eclipse3.4 和 p2 机制开始,你可以使用 < a href="http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/osgi/service/datalocation/Location.html " rel="noreferrer">
org.eclipse.osgi.service.datalocation.Location
,表示 URL。该接口包括 **
ECLIPSE_HOME_FILTER**
,一个常量,它定义用于获取指定 eclipse home 位置的服务的过滤器字符串(即“eclipse.home.location
”)。 )但在eclipse3.3中,只需查询属性值“
eclipse.home.location
”即可,如下:Since eclipse3.4 and the p2 mechanism, you coud use
org.eclipse.osgi.service.datalocation.Location
, which represents a URL.That interface includes **
ECLIPSE_HOME_FILTER**
, a constant which defines the filter string for acquiring the service which specifies the eclipse home location (i.e. "eclipse.home.location
".)But in eclipse3.3, just query the property value "
eclipse.home.location
", as in:关于为什么需要安装路径有点疑问。 您的代码(插件)不应依赖于安装目录中的任何内容。 如果您正在考虑写入安装目录。 不! 您将无法在共享安装中执行此操作,无论如何这是一个非常糟糕的主意。
例如,如果您需要访问插件内的文件,您只需使用如下代码:
获取用户工作空间的位置
It is a bit questionable as to why you would need the installation path. Your code (a plugin) should not depend on anything in the installation directory. If you are thinking of writing to the installation directory. Don't! You won't be able to do that in a shared install and it's a very bad idea anyway.
If you for example need to access a file inside your plugin you would simply use code like this:
To get the location of the users workspace