Skip to content

Install

Martin Desruisseaux edited this page May 3, 2024 · 9 revisions

Installation instruction

The project has not yet been deployed on Maven Central, because we have not yet resolved how to include native libraries (see issue #40). For now it has to be built from sources. The steps are:

  • Install Java 11 or later.
  • Install PROJ.
  • If the proj-devel package is not included in above installation, install it in the same way as the proj package.
  • Install Apache Maven.
  • Clone PROJ-JNI and compile:
git clone https://github.com/OSGeo/PROJ-JNI
cd PROJ-JNI
mvn install

The results will be the following files in the target directory. The *.so file may have a different name depending on the host operating system.

  • proj-2.0-SNAPSHOT.jar
  • geoapi-3.0.2.jar (a dependency)
  • unit-api-2.1.3.jar (a dependency)
  • seshat-1.3.jar (copied for convenience but can be ignored – see below)
  • classes/org/osgeo/proj/libproj-binding.so (name may vary)

Only the *.jar files need to be kept (a copy of the *.so or *.dll file is bundled inside the proj-*.jar file). The JAR files should be kept together in the same directory for allowing automatic completion of class path (e.g. for running the example without specifying the dependencies). That directory can be anywhere.

It is recommended to add a JSR-385 (Units of Measurement) implementation on the class path. PROJ-JNI accepts any implementation. Examples are Indriya and Seshat. The latter supports some EPSG codes for Units of Measurement.

Build and run in Windows environment

In environments where the native libraries are not installed by a package manager, PROJ and its dependencies may not be found automatically. If compilation produces many "unresolved external symbol" errors, then the build can be patched as below:

  • Defines OSGEO4W_DIR as an environment variable set to the directory where native OSGeo libraries are found.
  • Open the src/main/cpp/CMakeLists.txt file.
  • Find the find_library(PROJLIB proj) line.
  • Insert the following lines after above find line:
# Set explicitly on Windows because `find_library()` did not work.
set (PROJLIB $ENV{OSGEO4W_DIR}/lib/proj.lib)
set (PROJINC $ENV{OSGEO4W_DIR}/include)

Above should fixes compilation, but execution may still fail. In Windows environment, it may be necessary to load dependencies explicitly before to load the PROJ library. It can be done by adding the following lines in the application code, before any call to PROJ-JNI:

System.load("/path/to/sqlite3.dll");
System.load("/path/to/libcurl.dll");
System.load("/path/to/zlib1.dll");
System.load("/path/to/jpeg62.dll");
System.load("/path/to/lzma.dll");
System.load("/path/to/tiff.dll");
System.load("/path/to/proj.dll");
Clone this wiki locally