背景:开发、测试环境是windows系统,生产环境是linux,而SAP在这两个系统安装有所不同。

安装步骤:

  1. 将sapjco3.jar 文件复制至  $JAVA_HOME/lib/sapjco3.jar 。
  2. 将 libsapjco3.so 文件复制至 $JAVA_HOME/jre/lib/amd64/server/libsapjco3.so(可自行指定目录)
  3. 添加环境变量,export LD_LIBRARY_PATH=dir:$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/amd64/server
  4. 使环境变量生效,source /etc/profile
  5. 查看是否安装成功,执行java -jar/home/jdk1.8.0_112/lib/sapjco3.jar,如果成功则会弹出一下信息:
--------------------------------------------------------------------------------------
|                                 SAP Java Connector                                 |
|                Copyright (c) 2000-2016 SAP SE. All rights reserved.                |
|                                Version Information                                 |
--------------------------------------------------------------------------------------
Java Runtime:
 Operating System:       Linux 2.6.32-431.el6.x86_64 for amd64
 Java VM:                1.7.0_75 Oracle Corporation
 Default charset:        UTF-8
Versions:
 JCo API:                3.0.16 (2016-12-06)
 JCo middleware:         JavaRfc 2.2.19
 JCo library:            721.800
Library Paths:
 Path to JCo archive:    /opt/jdk1.7.0_75/lib/sapjco3.jar
 Path to JCo library:    /usr/local/tools/jco3/libsapjco3.so
--------------------------------------------------------------------------------------
|                                      Manifest                                      |
--------------------------------------------------------------------------------------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.4
Implementation-Title: com.sap.conn.jco
Implementation-Version: 20161207 2131 [3.0.16 (2016-12-06)]
Specification-Vendor: SAP SE, Walldorf
Specification-Title: SAP Java Connector v3
Implementation-Vendor-Id: com.sap
Created-By: 5.1.028 (SAP AG)
Specification-Version: 3.0.16

本人在安装成功之后,项目处于启动状态,直接调用SAP接口,报出了Could not initialize xxx,类似这样的错误(当时没有截图,大概是这样子啦~~)。于是重启项目,之后又报出java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.JCo这样的错误。

解决:将sapjco3.jar复制了一份放在项目的lib包下,重新启动,问题解决!

 
Logo

更多推荐