我在mac上给eclipse 安装 svn插件 是参考下面的文章
但是在使用brew安装的过程中遇到无法安装javaHl 原来是没有安装xcode工具
所以先下载xcode 比较大 大概有4个G吧
文章出处:http://www.cnblogs.com/yinxiangpei/articles/3859057.html
eclipse中最常使用的SVN插件是subclipse,先到subclipse官网:http://subclipse.tigris.org下载该插件。
id="iframe_0.1646071822533144" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313K291-0.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.1646071822533144',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 578px; height: 339px;">
如上图,点击“Download and Install”转到下载页面。
id="iframe_0.5554991912591121" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313M3X-1.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5554991912591121',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 576px; height: 340px;">
选择上图中要安装的版本,比如我这里选择:Links for 1.8.x Release:
接下来,有两种方式来安装subclipse,二选一即可。
一、
1、复制Eclipse update site URL:后边的链接:http://subclipse.tigris.org/update_1.8.x
2、打开eclipse,点击Help-Install New SoftWare,打开窗口:
id="iframe_0.005961870563802485" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313G927-2.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.005961870563802485',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 828px; height: 232px;">
3、点击add按钮。
4、在name一栏中输入插件名称:subclipse;
location一栏中输入刚才拷贝的链接:http://subclipse.tigris.org/update_1.8.x
id="iframe_0.48003842628768667" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313G224-3.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.48003842628768667',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 476px; height: 172px;">
5、点击Ok。
id="iframe_0.7609877722970804" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313MI7-4.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7609877722970804',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 740px; height: 445px;">
6、如上图,选中Subclipse,并去掉下边Contact all update site...选项前面的勾,然后一路next,直到在线安装完成,如果中间出现提示框,选择OK即可。安装完成会要求你重启eclipse。
二、
1、点击Zipped downloads后面的链接,将该插件下载到本地。
2、同上2
3、同上3
4、在name一栏中输入:subclipse ,点击Archive按钮,选择刚刚下载的插件包。
id="iframe_0.1148812223916651" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313J236-5.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.1148812223916651',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 470px; height: 179px;">
5、同上5
6、同上6
重启eclipse后,选择Window-Show View-Other
展开SVN,双击打开“SVN资源库”视图
id="iframe_0.26016285099620995" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313Kc6-6.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.26016285099620995',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 500px; height: 155px;">
在空白处右击,选择新建-资源库位置
id="iframe_0.6777362645457778" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313Kc8-7.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6777362645457778',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 439px; height: 184px;">
id="iframe_0.2580286855953611" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313LO5-8.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.2580286855953611',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 510px; height: 231px;">
在上图URL一栏中输入SVN访问地址,然后finish,这时候会提示错误:
Failed to load JavaHL Library.
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
no svnjavahl-1 in java.library.path
no svnjavahl in java.library.path
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
no svnjavahl-1 in java.library.path
no svnjavahl in java.library.path
java.library.path = .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
说明系统缺少JavaHL,需要我们手动安装。
点击Eclipse-Preferences,展开Team-SVN
id="iframe_0.22241382483499228" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313K0I-9.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.22241382483499228',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 810px; height: 144px;">
从上图也可以看出,SVN接口下边的client显示的是:JavaHL(JNI)Not Available
意思是JavaHL不可用。当然你也可以点击右边的上下箭头来选择 SVNKit...作为client,这样也可以正常使用subclipse,
但是官方建议使用JavaHL作为client,稳定性,速度性都比SVNKit好很多,使用SVNKit有可能出现未知的错误,使你的项目数据受损。(javaHL是通过jni的方式来调用本地的SVN库,所以说速度快,稳定可靠)
id="iframe_0.47535235686311017" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313I061-10.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.47535235686311017',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 395px; height: 80px;">
查看JavaHL的Wiki文档:http://subclipse.tigris.org/wiki/JavaHL
在下边的OS X中提到:要安装JavaHL需要借助MacPorts或者HomeBrew。(说明:MacPorts和HomeBrew是Mac OS X中的包管理器,类似于Ubuntu中的apt-get和Red Hat的yum,用于安装、卸载、更新软件等)
id="iframe_0.8896081500415147" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313II3-11.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8896081500415147',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 883px; height: 268px;">
接下来我们使用MacPorts来安装JavaHL,进入MacPorts的下载页面:http://www.macports.org/install.php
id="iframe_0.8554477989055784" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313J230-12.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8554477989055784',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 724px; height: 149px;">
上图中的一段话说明,要安装和运行MacPorts,必须要安装Xcode和Command Line Tools,那么就去Mac App Store下载安装Xcode,免费的,1.65个G。Xcode安装完,打开,点击Xcode-Preferences,切换到Downloads视图,点击下边Command Line Tools后面的Install按钮进行安装。
id="iframe_0.010101115383465809" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313IG6-13.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.010101115383465809',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 721px; height: 310px;">
Xcode和Command Line Tools安装完成之后,回到MacPorts的下载页面,点击下图中的带下划线的系统版本进行下载。我的系统版本是Mountain Lion,所以就点击“Mountain Lion”下载。
id="iframe_0.9107792180236836" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313J116-14.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.9107792180236836',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 742px; height: 254px;">
下载后,直接点击安装即可,安装过程可能会非常慢,当时我以为安装不下去了,就打算重启电脑,谁知道突然提示说安装完毕。如果你的安装过程一直不动 ,建议重启电脑多试几次。
MacPorts装完之后,打开终端,按照JavaHL的WIKI文档说明,输入:sudo port install subversion-javahlbindings +no_bdb +universal 回车,最后出现一个错误,安装失败!连续试了几次都是如此。看网上很多人都出现了MacPorts安装JavaHL不成功的情况,有人说用HomeBrew可以成功,所以我又改用HomeBrew来安装JavaHL。
由于MacPorts和HomeBrew不兼容,所以我们先把MacPorts卸载。
在终端中输入:
sudo port -f uninstall installed
sudo rm -rf \
/opt/local \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
/Library/Receipts/MacPorts*.pkg \
/Library/StartupItems/DarwinPortsStartup \
/Library/Tcl/darwinports1.0 \
/Library/Tcl/macports1.0 \
~/.macports
MacPorts卸载删除完毕,然后打开HomeBrew的主页:http://brew.sh
将页面拖到最下边,看到下图:
id="iframe_0.23204745103748126" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313J205-15.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.23204745103748126',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 870px; height: 282px;">
上边白色的一行命令就是用来安装HomeBrew的,可以看到它是一条Ruby命令,说明HomeBrew是用Ruby来实现的。
因为Mac OS X 已经默认安装了Ruby,所以我们直接执行这条命令就可以了。不放心的可以在终端输入:ruby -v 来查看Ruby的版本。
在终端输入:ruby -e "$(curl -fsSLhttps://raw.github.com/mxcl/homebrew/go)"
回车,接下来就开始在线安装HomeBrew了,安装时间可能较长,视网络状况而定。homebrew默认是被安装在usr/local下,bin就是它的主目录,并且bin目录的路径已被加入path,在任意目录可以直接执行brew命令。通过brew安装的包都存放在use/local下的Cellar目录中。
当然,为了使目录结构更清晰,我们可以在/usr/local下创建homebrew目录,再将homebrew安装在/usr/local/homebrew下,具体的操作命令是,
终端输入:mkdir homebrew && curl -Lhttps://github.com/mxcl/homebrew/tarball/master| tar xz --strip 1 -C homebrew
安装完成后,需要更新下homebrew,终端输入:brew update
然后手动将/usr/local/homebrew/bin添加到PATH中即可。
Home Brew安装成功之后,接下来正式开始安装javaHL,终端输入:brew install --universal --java subversion
这个命令在javaHL的Wiki中可以找到)即可开始安装javaHL,安装完成后,它会提示你:You may need to link the Java bindings…….,然后执行下边的两个sudo命令:
终端输入:sudo mkdir -p /Library/Java/Extensions
sudo ln -s /usr/local/homebrew/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib
即可大功告成!
最后一行会显示JavaHL的版本。比如我的就是下边的这个样子:版本号是:1.8.0
id="iframe_0.4159394610108387" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313L407-16.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.4159394610108387',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 566px; height: 213px;">
这时候,我们打开eclipse,建立资源库时又出现一个错误:
Incompatible JavaHL library loaded. Subversion 1.7.x required.
这个错误是说不匹配的JavaHL版本被加载,需要的版本是1.7.x
上边提到我安装的JavaHL版本是1.8.0,打开JavaHL的Wiki文档:http://subclipse.tigris.org/wiki/JavaHL
id="iframe_0.03425565236645278" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313K2G-17.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.03425565236645278',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 559px; height: 341px;">
上图中的表格标识了subclipse与JavaHL的版本对应关系。
我的eclipse中安装的subclipse版本是1.8.22,对应的JavaHL版本应该是1.7.x,所以才会提示版本不匹配。
为了方便,我们把subclipse1.8.22卸载,换成1.10.x,这样就匹配了。
卸载subclipse步骤:打开eclipse,点击Eclipse-About Eclipse
id="iframe_0.22233693722169345" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313H125-18.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.22233693722169345',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 545px; height: 295px;">
点击Installation Details按钮,选中与subclipse相关的选项,然后点击Uninstall按钮就可以卸载了。
id="iframe_0.4220539488819215" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://www.chengxuyuans.com/uploads/allimg/130828/15313K227-19.png?_=3859057%22%20style=%22border:none;max-width:883px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.4220539488819215',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 691px; height: 631px;">
卸载完毕,然后按照上边提到的步骤重新下载安装subclipse 1.10.1,然后重启eclipse,就能够正常建立资源库位置了。