Eclipse绿色化方案

admin 2020年10月25日22:14:03评论428 views字数 3465阅读11分33秒阅读模式

Eclipse绿色化方案

标题: Eclipse绿色化方案

创建: 2020-10-24 22:03
更新:
链接: http://scz.617.cn:8/windows/202010242203.txt

https://www.eclipse.org/downloads/
https://mirrors.neusoft.edu.cn/eclipse/oomph/epp/2020-09/R/eclipse-inst-jre-win64.exe

在Win10上装2020-09这个版本。过去Eclipse有zip版本,不知何时只有exe版本了。

Eclipse不会往注册表里写东西,可以选择安装目录,假设当前用户名为scz,缺省安装目录是:

%USERPROFILE%eclipsejava-2020-09
C:Userssczeclipsejava-2020-09

为了做实验,选择安装目录为:

H:Eclipsejava-2020-09

不在启动菜单中增加相关项,只增加一个桌面快捷方式。它会自动下载JRE,有两种选择:

JRE 14.0.2 - https://download.eclipse.org/justj/jres/14/updates/release/14.0.2
JRE 11.0.2 - https://download.eclipse.org/justj/jres/11/updates/release/11.0.2

缺省是14,安装到:

%USERPROFILE%.p2poolpluginsorg.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_14.0.2.v20200815-0932jre
C:Usersscz.p2poolpluginsorg.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_14.0.2.v20200815-0932jre

剪切

H:Eclipse

H:GreenEclipse

执行

H:GreenEclipsejava-2020-09eclipseeclipse.exe

指定Workspace

H:workEclipse

可以启动。

查看"H:GreenEclipse"的大小,才17M,这个目录虽然可以移动,但它依赖其他目录:

C:Usersscz.eclipse  2.24M
C:Usersscz.p2       305M
C:Usersscz.tooling  132K

把这三个目录移动到

H:GreenEclipse.eclipse
H:GreenEclipse.p2
H:GreenEclipse.tooling

再次启动Eclipse,报错:

The Eclipse executable launcher was unable to locate its companion shared library.

显然Eclipse是假绿化状态,我想要的效果是,除了Workspace之外的所有相关目录都位于这个目录下:

H:GreenEclipse

重装OS时,只需要将这个目录备份、还原即可恢复Eclipse的使用。

用UltraEdit在"H:GreenEclipse"中搜索包含"scz"的所有文件,有如下命中:

H:GreenEclipse.eclipseorg.eclipse.oomph.p2agents.info
H:GreenEclipse.eclipseorg.eclipse.oomph.p2defaults.info
H:GreenEclipse.eclipseorg.eclipse.oomph.setupsetupsuser.setup                                             // 只有个用户名
H:GreenEclipse.p2pools.info
H:GreenEclipse.p2profiles.info
H:GreenEclipse.p2org.eclipse.equinox.p2.engine.settingsorg.eclipse.equinox.p2.artifact.repository.prefs
H:GreenEclipsejava-2020-09eclipseeclipse.ini
H:GreenEclipsejava-2020-09eclipseconfigurationconfig.ini
H:GreenEclipsejava-2020-09eclipseconfigurationorg.eclipse.equinox.simpleconfiguratorbundles.info
H:GreenEclipsejava-2020-09eclipseconfigurationorg.eclipse.osgiframework.info.2                           // 二进制文件
H:GreenEclipsejava-2020-09eclipseconfigurationorg.eclipse.osgi165data1289483077artifacts.xml          // 后生成的
H:GreenEclipsejava-2020-09eclipseconfigurationorg.eclipse.osgi173datatimestamps-1968014569             // 后生成的
H:GreenEclipsejava-2020-09eclipseconfigurationorg.eclipse.updateplatform.xml

user.setup中只有个用户名scz,没有目录信息。framework.info.2是个二进制文件。其余文件都是文本文件,将其中的目录信息修正到"H:GreenEclipse",格式需要与原来的一致,尤其是正反斜杠。

再次执行

H:GreenEclipsejava-2020-09eclipseeclipse.exe

启动成功,但是仍然自动生成三个目录:

C:Usersscz.eclipse
C:Usersscz.p2
C:Usersscz.tooling

我希望将来只用到:

H:GreenEclipse.eclipse
H:GreenEclipse.p2
H:GreenEclipse.tooling
H:GreenEclipse.m2
H:GreenEclipse.gitconfig
H:GreenEclipsegit
H:GreenEclipse.ssh

修改

H:GreenEclipsejava-2020-09eclipseeclipse.ini

在"-vmargs"后增加环境变量:

-Duser.home=H:/Green/Eclipse

编辑

H:GreenEclipsejava-2020-09eclipseeclipse.bat
@echo off
set HOME=H:GreenEclipse
start "Run Eclipse" "H:GreenEclipsejava-2020-09eclipseeclipse.exe"

在桌面创建eclipse.bat的快捷方式,以后用eclipse.bat启动。

如果绿色化失败,可以看这个文件找找原因:

H:workEclipse.metadata.log

怎么知道要设置HOME环境变量的呢,就是从.log中看来的,git会用到这个环境变量。用bat文件的好处是,只需针对Eclipse进程设置HOME环境变量,不必设置全局环境变量。

如果绿色化成功,不会再在"C:Usersscz"下生成那些目录。

然后过一遍配置,在配置中会发现所有目录都位于"H:GreenEclipse"之下,除了Workspace。

至此,Eclipse绿色化完成。

注意到绿色化过程的主要麻烦在于会在%USERPROFILE%下生成一堆目录,为此尝试过这种安装过程:

set HOME=H:GreenEclipse
set USERPROFILE=H:GreenEclipse
start "Install Eclipse" eclipse-inst-jre-win64-2020-09.exe

实测表明安装过程无论如何都会在"C:Usersscz"下生成一堆目录。换句话说,要想"All In One",只能像再前面那样干。

本文始发于微信公众号(青衣十三楼飞花堂):Eclipse绿色化方案

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2020年10月25日22:14:03
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Eclipse绿色化方案http://cn-sec.com/archives/170035.html

发表评论

匿名网友 填写信息