From 4227bf6ab9a5695a624e032c7f832bd0c99f7535 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 9 Apr 2010 09:01:13 -0700 Subject: [PATCH] (SIGAR-214) properly adjust jni.javahome when JAVA_HOME is not set --- bindings/java/hyperic_jni/jni-build.xml | 13 ++++--------- .../src/org/hyperic/jni/ArchNameTask.java | 11 +++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bindings/java/hyperic_jni/jni-build.xml b/bindings/java/hyperic_jni/jni-build.xml index 3601e133..3dbb548c 100644 --- a/bindings/java/hyperic_jni/jni-build.xml +++ b/bindings/java/hyperic_jni/jni-build.xml @@ -54,15 +54,6 @@ USA. - - - - - - - java.home=${jni.javahome} - - @@ -180,6 +171,10 @@ USA. + java.home=${jni.javahome} + + + diff --git a/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java b/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java index 5a991b99..46bf2976 100644 --- a/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java +++ b/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java @@ -138,6 +138,17 @@ public class ArchNameTask extends Task { } } getProject().setProperty("jni.scmrev", getSourceRevision()); + + //jni.javahome required to find include/jni.h + String home = getProject().getProperty("jni.javahome"); + if (home == null) { + home = System.getProperty("java.home"); + } + File dir = new File(home); + if (!new File(dir, "include").exists()) { + dir = dir.getParentFile(); //was /jre + } + getProject().setProperty("jni.javahome", dir.getPath()); } //XXX source rev stuff should be in another task