Eclipse plugin 如何获得Eclipse安装目录的绝对路径?
我正在编写一个Eclipse产品,由插件组成。Eclipse plugin 如何获得Eclipse安装目录的绝对路径?,eclipse-plugin,directory,installation,Eclipse Plugin,Directory,Installation,我正在编写一个Eclipse产品,由插件组成。 在我的一个插件中,我需要获得安装Eclipse的目录的绝对路径。 (即Mac上的/Applications/Eclipse或Win上的C:\Program Files\Eclipse) 找不到此的API。想法?建议: 下面给出了安装位置 见 应该是 Platform.getInstallLocation().getURL() 奇怪的是,getInstanceLocation似乎提供了当前的eclipse工作区。然而,Platform.getIns
在我的一个插件中,我需要获得安装Eclipse的目录的绝对路径。
(即Mac上的
/Applications/Eclipse
或Win上的C:\Program Files\Eclipse
)
找不到此的API。想法?建议:
下面给出了安装位置
见
应该是
Platform.getInstallLocation().getURL()
奇怪的是,getInstanceLocation似乎提供了当前的eclipse工作区。然而,Platform.getInstallLocation().getURL()提供了我所需要的东西,我通过研究平台的其余方法发现了这一点。谢谢上述答案的第一部分应该删除。”“实例位置”只是“工作区”的另一个名称,而这不是要求的。第二部分是正确答案。
/**
* 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
*/
Platform.getInstallLocation().getURL()