長久以來一直為RCP的文件路徑獲取在IDE環(huán)境時(shí)和產(chǎn)品發(fā)布時(shí)不同苦惱不已,今天終于可以宣布已經(jīng)fix了這個(gè)難題。
檢測(cè)報(bào)告如下:
在eclipse中運(yùn)行時(shí)得到的路徑結(jié)果:
Platform.getLocation().toString():E:/Eclipse/runtime-operationtool.product
Platform.getProduct().getDefiningBundle().getLocation():initial@reference:E:/Eclipse/workspace/operationtool/
Activator.getDefault().getBundle().getLocation():initial@reference:E:/Eclipse/workspace/operationtool/
Platform.getLogFileLocation():E:/Eclipse/runtime-operationtool.product/.data/.log
Platform.getInstallLocation():/D:/Program Files/eclipse/
Platform.getStateLocation(Activator.getDefault().getBundle()):E:/Eclipse/runtime-operationtool.product/.data/.plugins/operationtool
Platform.getUserLocation():/C:/Documents and Settings/Allen/user/
Platform.getInstanceLocation():/E:/Eclipse/runtime-operationtool.product/
Platform.getConfigurationLocation():/E:/Eclipse/workspace/.data/.plugins/org.eclipse.pde.core/operationtool.product/
在發(fā)布后運(yùn)行時(shí)得到的路徑結(jié)果,operationtool_1.0.0.jar未解壓:
Platform.getLocation().toString():E:/product/tool/workspace
Platform.getProduct().getDefiningBundle().getLocation():initial@reference:plugins/operationtool_1.0.0.jar/
Activator.getDefault().getBundle().getLocation():initial@reference:plugins/operationtool_1.0.0.jar/
Platform.getLogFileLocation():E:/product/tool/workspace/.data/.log
Platform.getInstallLocation():/E:/product/tool/
Platform.getStateLocation(Activator.getDefault().getBundle()):E:/product/tool/workspace/.data/.plugins/operationtool
Platform.getUserLocation():/C:/Documents and Settings/Allen/user/
Platform.getInstanceLocation():/E:/product/tool/workspace/
Platform.getConfigurationLocation():/E:/product/tool/configuration/
在發(fā)布后運(yùn)行時(shí)得到的路徑結(jié)果,operationtool_1.0.0.jar已解壓,并刪除operationtool_1.0.0.jar:
Platform.getLocation().toString():E:/product/tool/workspace
Platform.getProduct().getDefiningBundle().getLocation():initial@reference:plugins/operationtool_1.0.0/
Activator.getDefault().getBundle().getLocation():initial@reference:plugins/operationtool_1.0.0/
Platform.getLogFileLocation():E:/product/tool/workspace/.data/.log
Platform.getInstallLocation():/E:/product/tool/
Platform.getStateLocation(Activator.getDefault().getBundle()):E:/product/tool/workspace/.data/.plugins/operationtool
Platform.getUserLocation():/C:/Documents and Settings/Allen/user/
Platform.getInstanceLocation():/E:/product/tool/workspace/
Platform.getConfigurationLocation():/E:/product/tool/configuration/
通過對(duì)檢測(cè)報(bào)告分析,得出以下有用的幾個(gè)API的結(jié)論:
1.product的根目錄獲?。?div style="height:15px;">