您的位置:首页 > 编程语言 > Java开发

Eclipse Product 的启动过程

2014-03-04 22:31 211 查看
参考自:http://niub.iteye.com/blog/1807588

双击eclipse安装目录下的 eclipse.exe ,会加载同一目录下的 eclipse.ini 文件。示例:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar

--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
org.eclipse.epp.package.rcp.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m


<一> Eclipse 的JVM 启动时,找JRE 的顺序。

如果eclipse.ini中配置了-vm参数,那么则使用这个参数指定的JRE(jvm.dll库路径); 
否则,查看eclipse安装目录下是否有JRE文件夹,如果有的话就使用这个JRE; 
否则,去系统注册表中查找安装的JRE,如果还找不到就报错。 

<二>eclipse.ini

-startup 指定启动的入口为:安装目录下plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar 
会加载该jar包中的org.eclipse.equinox.launcher.Main.class类并调用其main(String)完成app的启动过程。

public static void main(String[] args) {
int result = 0;
...
result = new Main().run(args);
...
}
run() 方法会调用 basicRun() 方法。basicRun() 方法如下:

protected void basicRun(String[] args) throws Exception {
//记录启动启动时间
System.getProperties().put("eclipse.startTime", Long.toString(System.currentTimeMillis())); //$NON-NLS-1$
commands = args;
//处理Command参数,并根据Command参数设置默认属性
String[] passThruArgs = processCommandLine(args);

if (!debug)
// debug can be specified as system property as well
debug = System.getProperty(PROP_DEBUG) != null;
setupVMProperties();//将VM参数写入到System.Properties中
processConfiguration();//加载配置信息

getInstallLocation();//获取安装路径,这里调用一下是为了确保InstallLocation被初始化

// locate boot plugin (may return -dev mode variations)
URL[] bootPath = getBootPath(bootLocation);//获取启动路径列表

setupJNI(bootPath);//启动JNIBridge,加载dll类库

//检查JDK版本
if (!checkVersion(System.getProperty("java.version"),
System.getProperty(PROP_REQUIRED_JAVA_VERSION)))
return;

//检查配置信息
if (!checkConfigurationLocation(configurationLocation))
return;

setSecurityPolicy(bootPath);//设置安全策略

handleSplash(bootPath);//启动闪屏,就是Eclipse(或RCP启动时IDE打开前带有进度条的界面)

beforeFwkInvocation();

invokeFramework(passThruArgs, bootPath);//加载框架(前面的工作都是辅助,这个才是加载框架的核心)
}
<三> 各个方法简要说明,

1.processConfiguration():处理配置信息
,通过 config.ini 文件。

2.getInstallLocation():
获取当前安装路径。

3.getBootPath():获取启动路径列表


4.setupJNI():启动JNIBridge,加载dll类库


5.invokeFramework():启动Equinox框架
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: