Как я могу получить абсолютный путь к каталогу установки Eclipse? - PullRequest
12 голосов
/ 21 декабря 2010

Я пишу продукт Eclipse, состоящий из плагинов.
В одном из моих плагинов мне нужно получить абсолютный путь к каталогу, где установлен Eclipse. (т. е. /Applications/Eclipse на Mac или C:\Program Files\Eclipse на Win).

Не могу найти API для этого. Идеи?

Ответы [ 2 ]

12 голосов
/ 21 декабря 2010

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
 */
4 голосов
/ 16 июля 2014

должно быть

Platform.getInstallLocation().getURL()
...