站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Eclipse 专题Eclipse编程Tips(2)-让RCP自带JRE

Eclipse编程Tips(2)-让RCP自带JRE

摘要: Eclipse编程Tips(2)-让RCP自带JRE
有些时候我们编写的程序可能会用到其它一些库,比如JAI, J3D等,而在默认JRE中并没有这些库。一种方法是在用户的客户端上安装这些库,但是还有另外一种简单的方法,那就是自带JRE,把这些库全部放进JRE的响应目录中。这样无论客户端安装什么版本的JRE,是不是有全部的库,我们的应用程序总能够通过自己的JRE运行。
其方法是在RCP目录中,自建一个目录,就叫,里面就放入集成的JRE,把需要的库全部统统放进去就可以了。
原来,在eclipse.c中,有查找shipped VM的代码,eclipse.exe会先查找有没有自带的JVM,有的话就用它启动:
/* Find the directory where the Eclipse program is installed. */
programDir = getProgramDir();
...

/* If the user did not specify a VM to be used */
if (vmName == NULL)
{
/* Determine which type of VM should be used. */
vmName = ((debug || needConsole) ? consoleVM : defaultVM);

/* Try to find the VM shipped with eclipse. */
shippedVM = malloc( (_tcslen( programDir ) + _tcslen( shippedVMDir ) + _tcslen( vmName ) + 10) * sizeof(_TCHAR) );
_stprintf( shippedVM, _T_ECLIPSE("%s%s%s"), programDir, shippedVMDir, vmName );
javaVM = findCommand( shippedVM );

/* Format a message to indicate the default VM search path. */
vmSearchPath = malloc( (_tcslen( pathMsg ) + _tcslen( shippedVM ) + _tcslen( vmName ) + 10) * sizeof(_TCHAR) );
_stprintf( vmSearchPath, pathMsg, shippedVM, vmName );
free( shippedVM );
shippedVM = NULL;
}

eclipseWin.h
_TCHAR* consoleVM = _T("java.exe");
_TCHAR* defaultVM = _T("javaw.exe");
_TCHAR* shippedVMDir = _T("jre\\bin\\");

这样就可以通过自带JRE解决客户端库不完全的问题。我们的项目正是采用这种方式。


↑返回目录
前一篇: 关于Eclipse draw2d的FanRouter
后一篇: eclipse+myeclipse+mysql服务器tomcat