From 0a3a59853d7ecb88ce645cd980a5197217447213 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 14:59:37 +0200 Subject: After javac has generated org_proj4_PJ.h, move that file to the C source directory. --- jniwrap/build.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jniwrap/build.xml b/jniwrap/build.xml index ddd424bd..6e4703ec 100644 --- a/jniwrap/build.xml +++ b/jniwrap/build.xml @@ -23,6 +23,13 @@ includeAntRuntime = "false" includes = "org/**/*.java"/> + + + + + + + -- cgit v1.2.3 From 66cfd66f512b9c6accb3e045c7683b9df63b887d Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 15:01:41 +0200 Subject: Use more explicit java options in the documentation (e.g. --class-path instead of -cp). --- jniwrap/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jniwrap/README.md b/jniwrap/README.md index 3cce43c0..3a6b35be 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -42,7 +42,7 @@ Beyond the ones already put by PROJ, you need: * Ant 1.9.8+, to run the build. * For execution: * If a Java version less than the current version on the local machine is desired, - add an `release` attribute in the `javac` task of `build.xml`. + add a `release` attribute in the `javac` task of `build.xml` before to compile. @@ -107,10 +107,10 @@ we assume that PROJ was compiled with the right flag to support the bridge to Ja Therefore we have a library called `proj.jar`. Thus we compile the `Main.java` with the command: - javac -classpath /proj.jar Main.java + javac --class-path /proj.jar Main.java and execute the created test case with: - java -cp .:/proj.jar -Djava.library.path= Main + java --class-path .:/proj.jar -Djava.library.path= Main That's it, enjoy! -- cgit v1.2.3 From 1830abc903c74b228de918a2830324006df7176a Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 15:13:41 +0200 Subject: Add troubleshoting indication based on https://github.com/OSGeo/proj.4/issues/380 comments. --- jniwrap/README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/jniwrap/README.md b/jniwrap/README.md index 3a6b35be..e5748cda 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -101,9 +101,9 @@ Of course, real applications would read them from a file or other data source. -### compile the Main code +### Compile the Main code -we assume that PROJ was compiled with the right flag to support the bridge to Java +We assume that PROJ was compiled with the right flag to support the bridge to Java. Therefore we have a library called `proj.jar`. Thus we compile the `Main.java` with the command: @@ -113,4 +113,15 @@ and execute the created test case with: java --class-path .:/proj.jar -Djava.library.path= Main -That's it, enjoy! + + +### Troubleshooting + +If an `java.lang.UnsatisfiedLinkError` is thrown at execution time, add the following line in the Java code: + + System.out.println(System.getProperty("java.library.path")); + +Then verify that the `libproj.so` (Linux), `libproj.dylib` (MacOS) or `libproj.dll` (Windows) file is located +in one of the directories listed by above code. If this is not the case, then try configuring the +`LD_LIBRARY_PATH` (Linux), `DYLD_LIBRARY_PATH` (MacOS) or `PATH` (Windows) environment variable. +If the problem persist, adding the `-verbose:jni` option to the `java` command may help more advanced diagnostics. -- cgit v1.2.3 From 54f0513aed8a82e75f6442b4b03900c47f1c3621 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 16:25:54 +0200 Subject: Set the "PROJ bridge to JNI" version number to 3.0 and document its relationship with PROJ version number. --- jniwrap/README.md | 20 +++++++++++++++++++- jniwrap/build.xml | 7 ++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/jniwrap/README.md b/jniwrap/README.md index e5748cda..d8435725 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -3,13 +3,30 @@ This is the third release of JNI wrappers for the main PROJ functions. The first release of JNI wrappers were created by http://www.hydrologis.com. The second release of JNI wrappers were created by http://www.geoapi.org. +This release is compatible with any PROJ versions from 4.9 to 5 +provided that PROJ has been compiled as described below. ## What is "PROJ bridge to Java" -_Proj bridge to Java_ is a small library of Java classes that wrap a few PROJ functions +_PROJ bridge to Java_ is a small library of Java classes that wrap a few PROJ functions by using the Java Native Interface (JNI). The main Java class is `org.proj4.PJ`. +A Java code example is given in the _Usage & a fast example_ section below. + + + +### Versions + +The PROJ bridge to Java does not follow the same version numbers than the main PROJ library +since the same JAR file can be compatible with a range of PROJ versions. +Version compatibility is given below: + + +Java bridge | Compatible with PROJ library +----------- | ---------------------------- +2.0 and 3.0 | 4.9 to 5+ +1.0 | 4.4.9 to 4.8 @@ -43,6 +60,7 @@ Beyond the ones already put by PROJ, you need: * For execution: * If a Java version less than the current version on the local machine is desired, add a `release` attribute in the `javac` task of `build.xml` before to compile. + * Proj version 4.9 or more recent compiled with the `--with-jni` option. diff --git a/jniwrap/build.xml b/jniwrap/build.xml index 6e4703ec..62eb536d 100644 --- a/jniwrap/build.xml +++ b/jniwrap/build.xml @@ -9,7 +9,7 @@ - + -- cgit v1.2.3 From aaf0f39a048d10106bb82983c8f918270680cc34 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 16:46:46 +0200 Subject: Update JNI README.md with a note that Windows users need to use a different path separator. --- jniwrap/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jniwrap/README.md b/jniwrap/README.md index d8435725..fcf0fc6f 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -127,9 +127,9 @@ Thus we compile the `Main.java` with the command: javac --class-path /proj.jar Main.java -and execute the created test case with: +and execute the created test case with (replace `:` by `;` on the Windows platform): - java --class-path .:/proj.jar -Djava.library.path= Main + java --class-path /proj.jar:. Main @@ -142,4 +142,5 @@ If an `java.lang.UnsatisfiedLinkError` is thrown at execution time, add the foll Then verify that the `libproj.so` (Linux), `libproj.dylib` (MacOS) or `libproj.dll` (Windows) file is located in one of the directories listed by above code. If this is not the case, then try configuring the `LD_LIBRARY_PATH` (Linux), `DYLD_LIBRARY_PATH` (MacOS) or `PATH` (Windows) environment variable. +Alternatively, a `-Djava.library.path=` option can be added to above `java` command. If the problem persist, adding the `-verbose:jni` option to the `java` command may help more advanced diagnostics. -- cgit v1.2.3 From 864b315f530cb26b3d9638b711c957baf0238d9e Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 17:18:10 +0200 Subject: Fix version history: Java bridge 2.0 was compatible with PROJ 4.8 (not 4.9) and above. The PROJ 4.8 version was compatible with both Java bridges 1.0 and 2.0. --- jniwrap/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jniwrap/README.md b/jniwrap/README.md index fcf0fc6f..5ff5a7fd 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -3,7 +3,7 @@ This is the third release of JNI wrappers for the main PROJ functions. The first release of JNI wrappers were created by http://www.hydrologis.com. The second release of JNI wrappers were created by http://www.geoapi.org. -This release is compatible with any PROJ versions from 4.9 to 5 +This release is compatible with any PROJ versions from 4.8 to 5 provided that PROJ has been compiled as described below. @@ -25,8 +25,8 @@ Version compatibility is given below: Java bridge | Compatible with PROJ library ----------- | ---------------------------- -2.0 and 3.0 | 4.9 to 5+ -1.0 | 4.4.9 to 4.8 +2.0 and 3.0 | 4.8 to 5+ +1.0 | 4.4.9 to 4.8 inclusive @@ -60,7 +60,7 @@ Beyond the ones already put by PROJ, you need: * For execution: * If a Java version less than the current version on the local machine is desired, add a `release` attribute in the `javac` task of `build.xml` before to compile. - * Proj version 4.9 or more recent compiled with the `--with-jni` option. + * Proj version 4.8 or more recent compiled with the `--with-jni` option. -- cgit v1.2.3 From 0f6b52eb186dbf813ccd3049806300c9c13931d2 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Sat, 12 May 2018 18:43:11 +0200 Subject: Be more careful about the files that we move to C 'src' directory: since there is no header files starting with "org_" except JNI files, moving the "org_*.h" file should guarantee that we will not overwrite non-JNI file. The use of wildcard is for "org_osgeo_..." which may be added in a future version. This commit also opportunistically fixes minimum Ant version number in documentation. --- jniwrap/README.md | 2 +- jniwrap/build.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jniwrap/README.md b/jniwrap/README.md index 5ff5a7fd..9cc97dac 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -56,7 +56,7 @@ Beyond the ones already put by PROJ, you need: * For compilation: * Java 9+, the Java standard development kit version 9 or above - * Ant 1.9.8+, to run the build. + * Ant 1.10+, to run the build. * For execution: * If a Java version less than the current version on the local machine is desired, add a `release` attribute in the `javac` task of `build.xml` before to compile. diff --git a/jniwrap/build.xml b/jniwrap/build.xml index 62eb536d..be82d411 100644 --- a/jniwrap/build.xml +++ b/jniwrap/build.xml @@ -27,7 +27,7 @@ - + -- cgit v1.2.3