如何获取Eclipse安装目录的绝对路径? [英] How can I get the absolute path to the Eclipse install directory?
本文介绍了如何获取Eclipse安装目录的绝对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的一个插件中,我需要获得安装Eclipse的目录的绝对路径。
(在Mac上的
/ Applications / Eclipse
或$ code> C:\Program Files\Eclipse 在Win上) 找不到一个API。想法?
解决方案
以下为您安装的位置
Platform.getInstallLocation()。getURL()
请参阅 org .eclipse.core.runtime.Platform
API
/ **
*返回运行平台的基本安装位置
*< code> null< / code>如果平台在没有配置位置的情况下运行,则返回。
*< p>
*此方法相当于获取< code> org.eclipse.osgi.service.datalocation.Location< / code>
*服务的属性type等于{@link位置#INSTALL_FILTER}。
*< / p>
* @返回平台安装区域的位置或< code> null< / code>如果没有
* @since 3.0
* @see位置#INSTALL_FILTER
* /
I am writing an Eclipse product, composed of plugins.
In one of my plugins, I need to get the absolute path to the directory where Eclipse is installed.
(i.e. /Applications/Eclipse
on Mac or C:\Program Files\Eclipse
on Win).
Can't find an API for this. Ideas?
解决方案
codejammer suggests:
The following gives you the installed location
Platform.getInstallLocation().getURL()
See the org.eclipse.core.runtime.Platform
API
/**
* Returns the location of the base installation for the running platform
* <code>null</code> is returned if the platform is running without a configuration location.
* <p>
* This method is equivalent to acquiring the <code>org.eclipse.osgi.service.datalocation.Location</code>
* service with the property "type" equal to {@link Location#INSTALL_FILTER}.
*</p>
* @return the location of the platform's installation area or <code>null</code> if none
* @since 3.0
* @see Location#INSTALL_FILTER
*/
这篇关于如何获取Eclipse安装目录的绝对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文