使用eclipse API读取eclipse安装路径

发布于 2024-07-15 11:21:39 字数 137 浏览 6 评论 0原文

我打开了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一袭白衣梦中忆 2024-07-22 11:21:39

从 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”即可,如下:

System.getProperty("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:

System.getProperty("eclipse.home.location");
流绪微梦 2024-07-22 11:21:39

关于为什么需要安装路径有点疑问。 您的代码(插件)不应依赖于安装目录中的任何内容。 如果您正在考虑写入安装目录。 不! 您将无法在共享安装中执行此操作,无论如何这是一个非常糟糕的主意。

例如,如果您需要访问插件内的文件,您只需使用如下代码:

Activator.getDefault().getBundle().getEntry(fileName);

获取用户工作空间的位置

Platform.getInstanceLocation().getURL().getPath();

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:

Activator.getDefault().getBundle().getEntry(fileName);

To get the location of the users workspace

Platform.getInstanceLocation().getURL().getPath();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文