1. 程式人生 > >rcp(外掛開發) 如何獲取eclipse or rcp的安裝目錄

rcp(外掛開發) 如何獲取eclipse or rcp的安裝目錄

如題:

如下:

import java.net.URL;

import org.eclipse.core.runtime.Platform;

public class StudioInstallPathUtil {

 public static String getStudioPath(){
  String path = null; 
  //因為getInstallLocation已經單例模式,所以在此我們沒必要單例了
  org.eclipse.osgi.service.datalocation.Location location = Platform.getInstallLocation(); 
  if (location != null) { 
      URL url = location.getURL(); 
      path = url.getPath(); 
      path=path.substring(1, path.length()-1);
  } 
  return path;
 }
}