From: Andrew R. <and...@us...> - 2004-06-29 08:42:07
|
Update of /cvsroot/plplot/plplot/bindings/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25505/bindings/java Modified Files: PLStreamc.java config.java.in Log Message: Alter java bindings to allow location of the wrapper library to be specfied through a java property (plplot.libdir). To use this you can add something like -Dplplot.libdir="/usr/local/lib/plplot5.3.1/java/" to you java command. Should help make code more relocatable and also help with getting "make check" to work in the build tree. Index: config.java.in =================================================================== RCS file: /cvsroot/plplot/plplot/bindings/java/config.java.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- config.java.in 29 Jun 2004 04:58:51 -0000 1.5 +++ config.java.in 29 Jun 2004 08:41:59 -0000 1.6 @@ -22,5 +22,6 @@ public class config { // Must be installed absolute path name of generated DLL - public static String libname = "@JAVAWRAPPER_HARDDIR@/@PLPLOTJAVAC_WRAP_DLL@"; + public static String libname = "@PLPLOTJAVAC_WRAP_DLL@"; + public static String libdir = "@JAVAWRAPPER_HARDDIR@/"; }; Index: PLStreamc.java =================================================================== RCS file: /cvsroot/plplot/plplot/bindings/java/PLStreamc.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PLStreamc.java 17 Jan 2004 16:41:37 -0000 1.3 +++ PLStreamc.java 29 Jun 2004 08:41:59 -0000 1.4 @@ -34,6 +34,7 @@ //---------------------------------------------------------------------------// package plplot.core; +import java.io.*; public class PLStreamc { @@ -43,12 +44,35 @@ // Static code block to get the PLplot java wrapper dynamic library loaded in. static { + File libname = null; + try { - System.load( plplot.core.config.libname ); - } catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + String libdir = System.getProperty("plplot.libdir"); + libname = new File(libdir+File.separatorChar+plplot.core.config.libname); + if (! libname.exists()) { + libname = null; + } + } catch ( Exception e) { + } + if (libname == null) { + libname = new File(plplot.core.config.libdir+File.separatorChar+plplot.core.config.libname); + if ( ! libname.exists() ) { + libname = null; + } + } + if (libname != null) { + try { + System.load( libname.getAbsolutePath() ); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + else { + System.err.println("Unable to find native code library.\n"); System.exit(1); } + } // Class data. |