native javahl cannot load libraries could not initialize class org.apache.subversion.javahl.SVNClien

1、系统环境

(1)客户端:MACOS 10.12.6

(2)客户端:Eclipse Java EE IDE for Web Developers.Version: 2018-09 (4.9.0) Build id: 20180917-1800

(3)服务端:Subversion version 1.8.19

2、解决SVN Connector报错

native javahl cannot load libraries could not initialize class org.apache.subversion.javahl.SVNClient

3、解决方法

(1)MACOS自带SVN,但是版本与公司用的版本不一致,为了版本一致,需要安装subversion1.8.19或者subversion-client1.8.19

系统自带版本:

➜  ~ svn --version

svn, version 1.9.4 (r1740329)

   compiled Nov  6 2017, 18:06:35 on x86_64-apple-darwin16.1.0

(2)使用brew安装1.8.19是靠不住的,因为brew只能搜索到最新的subversion: stable 1.10.2版本或者1.8,但是1.8版本不支持--with-java选项,安装时没有该选项就解决不了javaHL问题。

(3)在subversion官网查询到,http://opensource.wandisco.com/osx/1.8/1.8.19/可以提供osx的pkg下载,这里什么版本都有,相当丰富,比源码编译、brew安装指定版本要靠谱的多。

(4)我的macos版本是10.12.6,因此安装Subversion-Client-1.8.19_10.12.x.pkg,这里看到:/opt/subversion/lib/svn-javahl: This is where the Subversion Java bindings (JavaHL) will be installed,javaHL将会被安装。

(5)正常安装后,告诉Java到哪找javaHL的扩展库

sudo ln -s /opt/subversion/lib/libsvnjavahl-1.0.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib

(6)此时使用eclipse就可以愉快的连接subversion1.8.19了,SVN connector选项的报错也没有了。

4、附录

(1)javaHL是什么

官方介绍http://subclipse.tigris.org/wiki/JavaHL

JavaHL is a part of the Subversion project. Specifically, it is the Java language binding for the Subversion API. Subversion provides a layered API design that is delivered as native libraries (DLL's). The Subversion command line is simply one consumer of this API. The API is rich in functionality but is also maintained for backwards compatibility. This is the reason there are so many great Subversion clients and tools available, because there is a rich and stable API that provides all of the functionality you need. 

Subversion is written in C to provide excellent cross platform support, but also because C produces libraries that are easy to consume from virtually any other language. The Subversion project provides and maintains language bindings for Java, Perl, Python and Ruby. The latter three are provided via the SWIG library and its ability to interface languages with native libraries. JavaHL is a "High Level" API and is provided with custom written C++ code to serve as the JNI bridge between Java code and the native libraries. This design allows us to provide a nice Java API into Subversion. 

JavaHL consists of essentially four parts: 

  1. A relatively thin layer of Java code that provides the API that consumers can talk to from Java. 
  2. A C++ library (the JavaHL library or libsvnjavahl-1). The Java layer talks to this layer using Java Native Interface (JNI) calls. The C++ layer is where the "High Level" API is implemented. For example, Java may provide a simple API that says "Commit this list of files, using this commit message". The C++ layer takes care of memory management and performing all of the lower level Subversion API calls it takes to complete the request. 
  3. The Subversion libraries themselves. These are the same libraries that the command line client would install and use. Also, other Subversion clients, such as TortoiseSVN or AnkhSVN would also use these same libraries. 
  4. Subversion library dependencies. Subversion needs a number of external libraries to operate. The biggest is the Apache Portable Runtime (APR), but it also needs libraries like Neon for the HTTP client and OpenSSL to handle encryption etc. 

All four of these layers are needed for JavaHL to work and be used in an application.

(2)eclipse marketplace安装svn插件,我使用的是subversion - SVN Team Provider 4.0.5,连接svn server时,需要安装svn connector,svn connector我使用的是Native javaHL(具体版本号与你的服务端版本号要一致),而svn connector安装后却报错native javahl cannot load libraries could not initialize class org.apache.subversion.javahl.SVNClient,于是查找资料,发现了最靠谱的方法。下载pkg安装(不用担心与自己系统自带的svn版本冲突),然后创建软连接即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值