First, installation preparation
1, install the JDK: (Recommended to use the download package for installation, Yum installation method is not good management), the installation path is/opt/jdk1.7.0_80
2, install Tomcat: (recommended to use the download package for installation, Yum installation method is not good management), the installation path is/opt/tomcat
3. Install Swig:yum install-y Swig (Java calls gdal via Swig on Linux)
4. Installing Java ant:yum-y install ant (required at compile time)
Second, installation Gdal
1. Create the installation directory
Mkdir/usr/local/gis
Cd/usr/local/gis
2, installation Proj4,gdal through the package to achieve the projection
wget ftp://ftp.remotesensing.org/proj/proj-4.6.0.tar.gz
TAR-ZXVF proj-4.6.0.tar.gz
CD proj-4.6.0
./configure
Make
sudo make install
3, installation Gdal
Cd.. /
wget http://download.osgeo.org/gdal/1.11.4/gdal-1.11.4.tar.gz
TAR-XZVF gdal-1.11.4.tar.gz
CD gdal-1.11.4
./configure--with-static-proj4=/usr/local/lib/libproj.la--with-poppler--with-pg--with-curl--with-geos-- With-jpeg--with-png--with-expat--with-xerces--with-java=/opt/jdk1.7.0_80--with-jvm-lib=/opt/jdk1.7.0_80/jre/ Lib/amd64/server--with-jvm-lib-add-rpath=yes--with-mdb=yes
Note: When configure, you need to be aware of configuring PROJ4 and JDK paths
Make
sudo make install
4. Compiling gdal Java-related packages
CD./swig/java
Vim java.opt
Modified: Java_home =/opt/jdk1.7.0_80
Make (generates Gdal.jar packages and related class libraries)
5. Copy all the files just generated (mainly Gdal.jar and all. LA,. so files) to the Java Lib directory, mine is/opt/jdk1.7.0_80/jre/lib
6. Set the environment variables as follows
Export Ld_library_path=/opt/jdk1.7.0_80/jre/lib
Export Gdal_data=/usr/local/share/gdal
Export Classpath=/opt/jdk1.7.0_80/jre/lib/gdal.jar
Where gdal_data can be obtained by Gdal-config--datadir command
7, add/opt/jdk1.7.0_80/jre/lib to/ld.so.conf, otherwise call gdal will prompt Libgdaljni.so.0:cannot open shared object file:
Vim/etc/ld.so.conf adding/opt/jdk1.7.0_80/jre/lib
Sudo/sbin/ldconfig
Third, Java call Gdal
1. Debugging in Linux Eclipse
Set up run config, add two variables
Gdal_data=/usr/local/share/gdal
Ld_library_path=/opt/jdk1.7.0_80/jre/lib
Note that there are two run config, and run as application and run on server are respectively set
2. Running in Tomcat
Modify catalina.sh, add at the beginning
Export Gdal_data=/usr/local/share/gdal
Export Ld_library_path=/opt/jdk1.7.0_80/jre/lib
Linux installation gdal Java compilation environment