Eclipse Product 的启动过程

当双击eclipse.exe,它会读取eclipse.ini配置,根据-vm参数选择JRE,否则检查安装目录下的JRE或系统注册表。启动入口为org.eclipse.equinox.launcher_1.2.0.v20110502.jar,执行processConfiguration、getInstallLocation、getBootPath、setupJNI和invokeFramework等步骤,启动Equinox框架。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考自: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框架 。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值