说明:本文档以Engine10 for RedHat4.5为例,其它情况类似。
一、安装Java SDK
Engine10需要Java6 update16环境,具体可以参考:http://resources.arcgis.com/content/arcgis-engine/10.0/system-requirements
1.下载jdk-6u20-linux-i586.bin安装包,直接用root用户安装:
2.执行: chmod +x jdk-6u20-linux-i586.bin
3.执行: ./jdk-6u20-linux-i586.bin
(此时会出现JDK安装授权协议。按Enter浏览。直接按Ctrl+C,会出现“Do you agree to the above license terms? [yes or no]”。键入yes,同意授权。此时系统会开始解压jdk-6u20-linux-i586.bin)
4.解压完毕后,发现一个解压好的安装文件,该文件夹就是安装好的JDK目录(这里我安装的目录是/home/jdk1.6.0_20
5. 设置环境变量
进入/etc文件夹,找到文件.profile并打开。就是在这个文件的最后加上:
export JAVA_HOME=/home/jdk1.6.0_20
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
6.设置完毕后,保存文件。注消后,重新登录控制终端.
执行: java -version
如果出现java version “1.6.0”,说明JDK已经安装成功了!
二、安装Engine Runtime
1.创建新用户来安装Engine,如果已创建好用户,则切换到该用户,确保在该用户下java环境是有效的。
2.挂载Engine linux的安装盘或拷贝到相应目录,进入ArcGISEngineRT目录执行./Setup进行安装,安装过程中选Single User即可(安装过程需要图形界面,因此应该退出之前登陆的root用户,用安装Engine的用户登陆)。
3.注册许可
在/home/esrichina/arcgis/engine10.0目录下执行./authorizeSoftware调出注册界面
4.配置环境
用户的环境变量,.bash_profile文件如下:
export JAVA_HOME=/home/jdk1.6.0_20
export JRE_HOME=/home/jdk1.6.0_20/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:/home/esrichina/arcgis/engine10.0/java/lib/:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export LD_LIBRARY_PATH=/home/esrichina/arcgis/engine10.0/lib
当然java环境如果已生效可以不用在这里配置
在/home/esrichina/arcgis/engine10.0目录下有几个脚本可以自动配置环境:init_java.sh 、init_engine.sh、setenv_engine.sh,分别source让它们生效。每次登陆开启终端的时候都需要执行它们 (或者添加到启动脚本):
source /home/esrichina/arcgis/engine10.0/init_java.sh
source /home/esrichina/arcgis/engine10.0/init_engine.sh
source /home/esrichina/arcgis/engine10.0/setenv_engine.sh
补充一下Engine for Linux的环境资料:
Engine本地的库在/home/esrichina/arcgis/engine10.0/lib或bin目录下;
vmw的一些库在/home/esrichina/arcgis/engine10.0/vmw/mw/ lib-linux_optimized目录下,如果出现Could not load native libraries.
java.lang.UnsatisfiedLinkError: /home/esrichina/arcgis/engine10.0/bin/libntvinv.so: libatl.so: cannot open shared object file: No such file or directory
类似的错误,一般都是环境变量找不到这些lib目录导致的,检查这些环境变量是否生效(应该是在执行init_java.sh的时候会自动添加的):
ARCLICENSEHOME=/home/esrichina/.esriprogramfiles/localhost.localdomain/esri/License10.0
LD_PRELOAD=/home/jdk1.6.0_20/jre/lib/i386/libjsig.so
MWHOME=/home/esrichina/arcgis/engine10.0/vmw/mw
ARCENGINEHOME=/home/esrichina/arcgis/engine10.0
LD_LIBRARY_PATH=/home/esrichina/arcgis/engine10.0/Python26/lib:/home/esrichina/arcgis/engine10.0/bin:/home/esrichina/arcgis/engine10.0/com:/home/esrichina/.esriprogramfiles/localhost.localdomain/CommonFiles/ArcGIS/bin:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux_optimized:/home/esrichina/arcgis/engine10.0/vmw/mw/../misc/linux/gcc/fixed3/lib:/home/esrichina/arcgis/engine10.0/bin:::/usr/X11R6/lib:/usr/lib:/usr/local/lib:
PATH=/home/esrichina/arcgis/engine10.0/python26/bin:/home/esrichina/arcgis/engine10.0/vmw/mw/bin:/home/esrichina/arcgis/engine10.0/vmw/mw/bin-i86_linux:/home/esrichina/arcgis/engine10.0/vmw/mw/bin-linux_optimized:/home/jdk1.6.0_20/bin:/home/jdk1.6.0_20/jre/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/esrichina/bin:/usr/bin/X11:/home/esrichina/arcgis/engine10.0/bin
CLASSPATH=/home/jdk1.6.0_20/lib:/home/jdk1.6.0_20/jre/lib:/home/esrichina/arcgis/engine10.0/java/lib/:
SHLIB_PATH=/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux_optimized:/home/esrichina/arcgis/engine10.0/vmw/mw/../misc/linux/gcc/fixed3/lib:
AGSENGINEJAVA=/home/esrichina/arcgis/engine10.0/
ARCGISHOME=/home/esrichina/arcgis/engine10.0/
Engine for Linux使用了MainWin虚拟windows环境,在Engine安装目录vmw/mw目录下。在vmw下有初始化MainWin环境的脚本,主要也是设置一些必须的环境变量,如MWHOME。
MainWin在Linux/Unix操作系统上提供了类似于windows的环境,包括注册表、组件库等。比如我们可以通过regsvr32命令在MainWin虚拟系统上注册组件,注册的命令在/vmw/mw/bin-linux_opeimized目录下,和windows下的注册完全类似,也可以使用regedit命令编辑注册表。
Engine安装目录下还有个比较重要的目录,那就是隐藏的.Setup目录,调用该目录下的registerArcGISEngineRT可以用来完成Engine的注册,会在同目录下生成日志文件regfile-convert-import.log、ArcGISEngineRT_registration.log,将Engine的dll和olb文件转成.reg注册表文件,再倒入注册表。
Dll文件转成的reg文件在binreg目录下,olb文件转成的reg文件在comreg目录下。
当然,所有这些操作都是在安装Engine Runtime的时候会自动完成的。
三、可能遇到的问题
1、Can’t connect to X11 window server using ‘:0.0’ as the value of the DISPLAY variable
解决:图形化界面出不来导致的,用engine用户登陆系统,确保图形界面能出来。
2、执行java –jar test.jar命令,会在initializeVisualBeans这一步出现错误:
ArcGIS Engine on Linux with Java 6 requires a minimum stack size of 2MB.
The stack size should be specified as a VM argument, e.g. -Xss2m
解决:提示很清楚了,需要添加JVM的-Xss2m参数,但这个参数不能加在后面,否则会导致initializeVisualBeans出错,正确的写法:java –jar –Xss2m test.jar
注意,-Xss2m不能加在最后面
3、在Linux下面的ArcEngine已经正常安装成功,但在运行AE程序的时候,却会报错。错误信息如下:
Could not load native libraries. ArcGIS/bin should be added to LD_LIBRARY_PATH environment variable.
java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)
at com.esri.arcgis.system.EngineInitializer.a(Unknown Source)
at com.esri.arcgis.system.EngineInitializer.initializeEngine(Unknown Source)
at com.copote.gisServiceCenter.gsc.service.StopsLayer.main(StopsLayer.java:209)
出错的代码行,正是AO包中初始化License的方法。代码如下:
EngineInitializer.initializeEngine();
AoInitialize aoInitializer = new AoInitialize();
aoInitializer.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
解决:
在Linux下Engine的程序初始化许可也是这样做的,在这里报错不一定就是许可的问题,还可能与其它环境设置有关。如果Engine正常安装且注册了许可那么初始化许可就应该是没问题的。所以也可能是加载本地AO库的时候有问题。
具体来说有以下几种可能:
1)开发程序的机器上ArcGIS Engine的版本和部署的Linux机器不一致导致AO库版本不一致;
2)找不到本地ArcGIS\bin目录以致不能加载本地库,检查LD_LIBRARY_PATH环境变量是否正确设置且生效;
3)ArcGIS\bin目录下的库文件是否有正确的访问权限;
4)在arcgis安装目录下的两个脚本 setenv_engine.sh和init_engine.sh是否正确的source生效。可以将它们添加到/etc/.profile里去,确保每次登陆时都执行生效:
source /home/arcgis/init_java.sh
source /home/arcgis/init_engine.sh
source /home/arcgis/setenv_engine.sh
4、在engine程序运行之前,直接执行命令source /home /arcgis/init_java.sh,出现如下的错误信息:
“Expected file not found. Expected to find libjsig.so at: /usr/lib/jdk/jre/lib/i386/
Please check that this file exists and it has correct access permissions. Exiting.
*** Note: Only a 32-bit Java Virtual Machine is supported. A 64-bit JVM was found at /usr/lib/jdk.”
解决:按照错误提示补上/usr/lib/jdk/jre/lib/i386/下面所缺失的文件:libjsig.so.
在64位系统中使用64位JVM初始化Engine环境会出错,安装32-bit的idk,确保java环境变量是指向32位jdk的位置即可。
5、运行Engine程序出现错误提示信息:The registry server is not alive.
解决:这个应该是mw(即MainWin)产生的错误。MainWin是COM对象运行在Unix之上的虚拟内核。
Engine的应用程序在初始化执行initializeEngine或initializeVisualBeans的时候就会通过MainWin来执行,通常我们是不需要去关心它的。
可以执行一下export MWRT_MODE=professional,设置engine runtime的mw运行模式,然后再source init_java.sh,source engine_java.sh。。。。。
还是不行的话,运行 ArcGIS安装目录/.Setup目录下的unregisterArcGISEngineRT、registerArcGISEngineRT重新注册Engine环境。
附:
在Engine用户下设置好环境变量脚本后,输入env查看环境:
ARCLICENSEHOME=/home/esrichina/.esriprogramfiles/localhost.localdomain/esri/License10.0
SSH_AGENT_PID=4113
HOSTNAME=localhost.localdomain
MWNEVER_USE_INPUT_METHOD=1
MWUSER_DIRECTORY=/home/esrichina/.arcgis10.0
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
MWVISUAL_DEPTH=24
LD_PRELOAD=/home/jdk1.6.0_20/jre/lib/i386/libjsig.so
GTK_RC_FILES=/etc/gtk/gtkrc:/home/esrichina/.gtkrc-1.2-gnome2
MWWINHELP_DIR=/home/esrichina/arcgis/engine10.0/help
WINDOWID=39845963
OLDPWD=/home/esrichina/arcgis
MWHOME=/home/esrichina/arcgis/engine10.0/vmw/mw
MWTHREAD_STACK=1FFFFF
ARCENGINEHOME=/home/esrichina/arcgis/engine10.0
JRE_HOME=/home/jdk1.6.0_20/jre
USER=esrichina
LD_LIBRARY_PATH=/home/esrichina/arcgis/engine10.0/python26/lib:/home/esrichina/arcgis/engine10.0/bin:/home/esrichina/arcgis/engine10.0/com:/home/esrichina/.esriprogramfiles/localhost.localdomain/CommonFiles/ArcGIS/bin:/home/esrichina/arcgis/engine10.0/python26/lib:/home/esrichina/arcgis/engine10.0/bin:/home/esrichina/arcgis/engine10.0/com:/home/esrichina/.esriprogramfiles/localhost.localdomain/CommonFiles/ArcGIS/bin:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux_optimized:/home/esrichina/arcgis/engine10.0/vmw/mw/../misc/linux/gcc/fixed3/lib:/home/esrichina/arcgis/engine10.0/lib:::/usr/X11R6/lib:/usr/lib:/usr/local/lib:.:/usr/lib:/usr/local/lib:.
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
GNOME_KEYRING_SOCKET=/tmp/keyring-Ac45VE/socket
SSH_AUTH_SOCK=/tmp/ssh-nCgGhW4112/agent.4112
PYHOME=/home/esrichina/arcgis/engine10.0/python26/bin
LIBPATH=/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux_optimized:/home/esrichina/arcgis/engine10.0/vmw/mw/../misc/linux/gcc/fixed3/lib::
MWCONFIG_NAME=linux
MWARCH=i86
SESSION_MANAGER=local/localhost.localdomain:/tmp/.ICE-unix/4081
lib_path_name=LD_LIBRARY_PATH
MWCURRENT_LIBPATH=/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux_optimized:/home/esrichina/arcgis/engine10.0/vmw/mw/../misc/linux/gcc/fixed3/lib
ESRI_INIT_ENGINE_RUN=yes
MWCORE_PRIVATE_DATA=/home/esrichina/.arcgis10.0/.localhost.localdomain
MWREGISTRY=/home/esrichina/.arcgis10.0/hklm_linux.bin
MWARCH_OS=i86_linux
MAIL=/var/spool/mail/esrichina
DESKTOP_SESSION=default
PATH=/home/esrichina/arcgis/engine10.0/python26/bin:/home/esrichina/arcgis/engine10.0/python26/bin:/home/esrichina/arcgis/engine10.0/vmw/mw/bin:/home/esrichina/arcgis/engine10.0/vmw/mw/bin-i86_linux:/home/esrichina/arcgis/engine10.0/vmw/mw/bin-linux_optimized:/home/jdk1.6.0_20/bin:/home/jdk1.6.0_20/jre/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/esrichina/bin:/usr/bin/X11:/home/esrichina/arcgis/engine10.0/bin:/home/esrichina/arcgis/engine10.0/bin
MW_TMPDIR=/tmp/esri_esrichina
ESRI_COMMON_FILES=/home/esrichina/.esriprogramfiles/localhost.localdomain/CommonFiles
MWCLEANUP_POLICY=full
INPUTRC=/etc/inputrc
PWD=/home/esrichina/arcgis/engine10.0
OGL_LIB_DIR=/dev/null
JAVA_HOME=/home/jdk1.6.0_20
MWWINHELP_PATH=/home/esrichina/arcgis/engine10.0/help
LANG=en_US.UTF-8
MWCURRENT_PATH=/home/esrichina/arcgis/engine10.0/vmw/mw/bin-linux_optimized
GDMSESSION=default
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
MWRT_MODE=professional
MWMULTI_MEM_SHARE=0
HOME=/home/esrichina
SHLVL=2
WINHELPPATH=.:/home/esrichina/.arcgis10.0/helpfile:/home/esrichina/arcgis/engine10.0/vmw/mw/helpfile
MWOS=linux
MWFONT_DIR_PATH=/home/esrichina/arcgis/engine10.0/fonts
GNOME_DESKTOP_SESSION_ID=Default
MWLOOK=windows
MWVISUAL_CLASS=TrueColor
PYTHONPATH=/home/esrichina/arcgis/engine10.0/bin
AWT_TOOLKIT=MToolkit
LOGNAME=esrichina
CLASSPATH=/home/jdk1.6.0_20/lib:/home/jdk1.6.0_20/jre/lib:/home/esrichina/arcgis/engine10.0/java/lib/:
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-RvZS0QWiGq
installDir=/home/esrichina/arcgis/engine10.0
LESSOPEN=|/usr/bin/lesspipe.sh %s
SHLIB_PATH=/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux:/home/esrichina/arcgis/engine10.0/vmw/mw/lib-linux_optimized:/home/esrichina/arcgis/engine10.0/vmw/mw/../misc/linux/gcc/fixed3/lib:
AGSENGINEJAVA=/home/esrichina/arcgis/engine10.0/
ARCGISHOME=/home/esrichina/arcgis/engine10.0/
X11_LIB_DIR=/usr/X11R6/lib
DISPLAY=:0.0
MWDIB_THREADS=1
MWRUNTIME=1
MWUSE_MIT_SHM=0
G_BROKEN_FILENAMES=1
COLORTERM=gnome-terminal
XAUTHORITY=/home/esrichina/.Xauthority
_=/usr/bin/env