如何获取Eclipse安装目录的绝对路径?

时间:2010-12-20 22:18:09

标签: eclipse-plugin directory install

我正在编写一个由插件组成的Eclipse产品 在我的一个插件中,我需要获取安装Eclipse的目录的绝对路径 (即Mac上的/Applications/Eclipse或Win上的C:\Program Files\Eclipse

无法找到此API。想法?

2 个答案:

答案 0 :(得分:12)

codejammer建议:

  

以下为您提供安装位置

Platform.getInstallLocation().getURL()

请参阅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
 */

答案 1 :(得分:4)

应该是

Platform.getInstallLocation().getURL()