[libgda] Java detection improvements



commit e77368ba68e6275e331c8a4f24b4b07cc81c2f6d
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Jun 3 18:08:51 2012 +0200

    Java detection improvements
    
    use java.home as well as java.library.path

 getsp.class |  Bin 1340 -> 1697 bytes
 getsp.java  |   31 ++++++++++++++++++++++++++++---
 m4/java.m4  |    2 +-
 3 files changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/getsp.class b/getsp.class
index d4e9227..ec4e45a 100644
Binary files a/getsp.class and b/getsp.class differ
diff --git a/getsp.java b/getsp.java
index c2e295f..f926129 100644
--- a/getsp.java
+++ b/getsp.java
@@ -8,28 +8,53 @@ public class getsp {
 			if (args[0].compareTo("-test")==0) {
 				System.out.println("Test1234OK");
 			}
-			else	if (args[0].compareTo("-libs")==0) {
+			else if (args[0].compareTo("-libs")==0) {
 				String prefix="-L";
 				if (args.length>1) prefix=args[1];
-				String lp=System.getProperty("java.library.path");
+
 				// we're not using StringTokenizer in case the JVM is very crude
 				int i=0,j,k=0;
 				String r=null;
 				String pss=System.getProperty("path.separator");
 				char ps=':';
 				if (pss!=null && pss.length()>0) ps=pss.charAt(0);
+
+				// using java.library.path
+				String lp=System.getProperty("java.home");
 				j=lp.length();
 				while (i<=j) {
 					if (i==j || lp.charAt(i)==ps) {
 						String lib=lp.substring(k,i);
+						String suffix="/lib/amd64/server";
+						k=i+1;
+						if (lib.compareTo(".")!=0)
+							r=(r==null)?(prefix+lib+suffix):(r+" "+prefix+lib+suffix);
+					}
+					i++;
+				}
+
+				// using java.home
+				lp=System.getProperty("java.library.path");
+				j=lp.length();
+				i=0;
+				k=0;
+				while (i<=j) {
+					if (i==j || lp.charAt(i)==ps) {
+						String lib=lp.substring(k,i);
 						k=i+1;
 						if (lib.compareTo(".")!=0)
 							r=(r==null)?(prefix+lib):(r+" "+prefix+lib);
 					}
 					i++;
 				}
+
 				if (r!=null) System.out.println(r);
-			} else
+			} else if (args[0].compareTo("-ldpath")==0) {
+				String lp1=System.getProperty("java.home")+"/lib/amd64/server";
+				String lp2=System.getProperty("java.library.path");
+				System.out.println(lp1+":"+lp2);
+			}
+			else
 				System.out.println(System.getProperty(args[0]));
 		}
 	}
diff --git a/m4/java.m4 b/m4/java.m4
index 7f8e264..dc1e121 100644
--- a/m4/java.m4
+++ b/m4/java.m4
@@ -215,7 +215,7 @@ m4_define([_JAVA_CHECK_INTERNAL],
 	                *)
 	                    RUN_JAVA(JAVA_LIBS, [-classpath ${srcdir} getsp -libs])
 	                    JAVA_LIBS="${JAVA_LIBS} -ljvm"
-	           	    RUN_JAVA(JAVA_LD_PATH, [-classpath ${srcdir} getsp java.library.path])
+			    RUN_JAVA(JAVA_LD_PATH, [-classpath ${srcdir} getsp -ldpath])
 	           	    ;;
 	            esac
 	            # note that we actually don't test JAVA_LIBS - we hope that the detection



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]