mac上給eclipse安裝svn插件

我在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
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,就能夠正常建立資源庫位置了。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章