From 5c961270fe3401ebb151b857e9e6bb3443aa0ffc Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 25 Apr 2007 17:13:06 +0000
Subject: [PATCH] Fix for issue 1273 (exception if JAVA_HOME undefined in scripts).

---
 opends/resource/upgrade       |    6 +++---
 opends/resource/uninstall.bat |   11 ++++++++++-
 opends/resource/uninstall     |    6 +++---
 opends/resource/setup         |    6 +++---
 opends/resource/upgrade.bat   |   12 +++++++++++-
 opends/resource/setup.bat     |   10 +++++++++-
 6 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/opends/resource/setup b/opends/resource/setup
index e2c0703..1e15f86 100755
--- a/opends/resource/setup
+++ b/opends/resource/setup
@@ -43,7 +43,7 @@
       then
         export JAVA_BIN
       else
-        echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+        echo "Please set JAVA_HOME to the root of a Java 5  (or later) installation."
         exit 1
       fi
     fi
@@ -102,7 +102,7 @@
     if test ${?} -ne 0
     then
       echo "ERROR:  The detected Java version could not be used.  Please set "
-      echo "        JAVA_HOME to the root of a Java 5.0 installation."
+      echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
       exit 1
     fi
   fi
@@ -111,7 +111,7 @@
   if test ${?} -ne 0
   then
     echo "ERROR:  The detected Java version could not be used.  Please set "
-    echo "        JAVA_HOME to the root of a Java 5.0 installation."
+    echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
     exit 1
   fi
 fi
diff --git a/opends/resource/setup.bat b/opends/resource/setup.bat
index e049d94..705b208 100644
--- a/opends/resource/setup.bat
+++ b/opends/resource/setup.bat
@@ -48,15 +48,23 @@
 
 :noSetJavaHome
 echo Error: JAVA_HOME environment variable is not set.
-echo        Please set it to a valid Java 5 installation.
+echo        Please set it to a valid Java 5 (or later) installation.
 goto end
 
+:noValidJavaHome
+echo ERROR:  The detected Java version could not be used.  Please set 
+echo         JAVA_HOME to to a valid Java 5 (or later) installation.
+goto end
 
 :setClassPath
 FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
+rem Test that the provided JDK is 1.5 compatible.
+"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
+if not %errorlevel% == 0 goto noValidJavaHome
+
 if "%*" == "" goto callLaunch
 goto callJava
 
diff --git a/opends/resource/uninstall b/opends/resource/uninstall
index 898d14d..01ce80b 100644
--- a/opends/resource/uninstall
+++ b/opends/resource/uninstall
@@ -43,7 +43,7 @@
       then
         export JAVA_BIN
       else
-        echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+        echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
         exit 1
       fi
     fi
@@ -101,7 +101,7 @@
     if test ${?} -ne 0
     then
       echo "ERROR:  The detected Java version could not be used.  Please set "
-      echo "        JAVA_HOME to the root of a Java 5.0 installation."
+      echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
       exit 1
     fi
   fi
@@ -110,7 +110,7 @@
   if test ${?} -ne 0
   then
     echo "ERROR:  The detected Java version could not be used.  Please set "
-    echo "        JAVA_HOME to the root of a Java 5.0 installation."
+    echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
     exit 1
   fi
 fi
diff --git a/opends/resource/uninstall.bat b/opends/resource/uninstall.bat
index 931054e..e071367 100644
--- a/opends/resource/uninstall.bat
+++ b/opends/resource/uninstall.bat
@@ -48,7 +48,12 @@
 
 :noSetJavaHome
 echo Error: JAVA_HOME environment variable is not set.
-echo        Please set it to a valid Java 5 installation.
+echo        Please set it to a valid Java 5 (or later) installation.
+goto end
+
+:noValidJavaHome
+echo ERROR:  The detected Java version could not be used.  Please set 
+echo         JAVA_HOME to to a valid Java 5 (or later) installation.
 goto end
 
 :setClassPath
@@ -56,6 +61,10 @@
 
 set PATH=%SystemRoot%
 
+rem Test that the provided JDK is 1.5 compatible.
+"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
+if not %errorlevel% == 0 goto noValidJavaHome
+
 if "%*" == "" goto callLaunch
 goto callJava
 
diff --git a/opends/resource/upgrade b/opends/resource/upgrade
index fca3240..f9612a6 100644
--- a/opends/resource/upgrade
+++ b/opends/resource/upgrade
@@ -47,7 +47,7 @@
         export JAVA_BIN
         export JAVAWS_BIN
       else
-        echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+        echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
         exit 1
       fi
     fi
@@ -111,7 +111,7 @@
     if test ${?} -ne 0
     then
       echo "ERROR:  The detected Java version could not be used.  Please set "
-      echo "        JAVA_HOME to the root of a Java 5.0 installation."
+      echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
       exit 1
     fi
   fi
@@ -120,7 +120,7 @@
   if test ${?} -ne 0
   then
     echo "ERROR:  The detected Java version could not be used.  Please set "
-    echo "        JAVA_HOME to the root of a Java 5.0 installation."
+    echo "        JAVA_HOME to the root of a Java 5 (or later) installation."
     exit 1
   fi
 fi
diff --git a/opends/resource/upgrade.bat b/opends/resource/upgrade.bat
index 7a3c0a9..3ec7e2d 100644
--- a/opends/resource/upgrade.bat
+++ b/opends/resource/upgrade.bat
@@ -53,13 +53,23 @@
 
 :noSetJavaHome
 echo Error: JAVA_HOME environment variable is not set.
-echo        Please set it to a valid Java 5 installation.
+echo        Please set it to a valid Java 5 (or later) installation.
+goto end
+
+:noValidJavaHome
+echo ERROR:  The detected Java version could not be used.  Please set 
+echo         JAVA_HOME to to a valid Java 5 (or later) installation.
 goto end
 
 set PATH=%SystemRoot%
 
+rem Test that the provided JDK is 1.5 compatible.
+"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
+if not %errorlevel% == 0 goto noValidJavaHome
+
 if "%*" == "" goto callWebStartUpgrade
 
+
 :callExtractor
 if EXIST .\tmp\upgrade rd .\tmp\upgrade /s /q
 set CLASSPATH=""

--
Gitblit v1.10.0