Index: /greenstone3/trunk/gs3-setup.bat
===================================================================
--- /greenstone3/trunk/gs3-setup.bat	(revision 17441)
+++ /greenstone3/trunk/gs3-setup.bat	(revision 17442)
@@ -47,5 +47,5 @@
 
 :: ---- Search for java ----
-winutil\search4j.exe -m %java_min_version% | winutil\setvar.exe _JRE_HOME > %TMP%\set_jre_home.bat
+winutil\search4j.exe -p %CD%/packages/jre -m %java_min_version% | winutil\setvar.exe _JRE_HOME > %TMP%\set_jre_home.bat
 call %TMP%\set_jre_home.bat
 del %TMP%\set_jre_home.bat
Index: /greenstone3/trunk/gs3-setup.sh
===================================================================
--- /greenstone3/trunk/gs3-setup.sh	(revision 17441)
+++ /greenstone3/trunk/gs3-setup.sh	(revision 17442)
@@ -4,6 +4,6 @@
 #the purpose of this file is to check/set up the environment for greenstone3
 #sorts out:
-#	- gsdl3home
-#	- java
+#  - gsdl3home
+#  - java
 
 # java_min_version gets passed to search4j as the minimum java version
@@ -23,10 +23,10 @@
 
   if test -n "$gsdl_not_sourced" ; then
-     echo "	Error: Make sure you source this script, not execute it. Eg:"
-     echo "		$ source gs3-setup.sh"
-     echo "	or"
-     echo "		$ . gs3-setup.sh"
-     echo "	not"
-     echo "		$ ./gs3-setup.sh"
+     echo "  Error: Make sure you source this script, not execute it. Eg:"
+     echo "    $ source gs3-setup.sh"
+     echo "  or"
+     echo "    $ . gs3-setup.sh"
+     echo "  not"
+     echo "    $ ./gs3-setup.sh"
      unset gsdl_not_sourced
      exit 1
@@ -42,111 +42,112 @@
 function setGS3ENV() {
 
-	echo "Setting up your environment for Greenstone3"
-	## main greenstone environment variables ##
-	GSDL3SRCHOME=`pwd`
-	GSDL3HOME=$GSDL3SRCHOME/web
-	export GSDL3HOME
-	export GSDL3SRCHOME
+  echo "Setting up your environment for Greenstone3"
+  ## main greenstone environment variables ##
+  GSDL3SRCHOME=`pwd`
+  GSDL3HOME=$GSDL3SRCHOME/web
+  export GSDL3HOME
+  export GSDL3SRCHOME
 
-	GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	# check for running bash under cygwin
-	if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then
-		GSDLOS=windows
-	fi 
-	export GSDLOS
-	echo "  - Exported GSDL3HOME, GSDL3SRCHOME and GSDLOS"
+  GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  # check for running bash under cygwin
+  if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then
+    GSDLOS=windows
+  fi 
+  export GSDLOS
+  echo "  - Exported GSDL3HOME, GSDL3SRCHOME and GSDLOS"
 
-	#change this if external tomcat
-	TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat
+  #change this if external tomcat
+  TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat
 
 
-	## adjustments to users (existing) environment ##
+  ## adjustments to users (existing) environment ##
 
-	#PATH
-	if [ `isinpath "$PATH" "$GSDL3SRCHOME/bin"` == "false" ]; then
-		PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
-		export PATH
-		MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
-		export MANPATH
-		echo "  - Adjusted PATH"
-	else
-		echo "  - PATH already correct"
-	fi
+  #PATH
+  if [ `isinpath "$PATH" "$GSDL3SRCHOME/bin"` == "false" ]; then
+    PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
+    export PATH
+    MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
+    export MANPATH
+    echo "  - Adjusted PATH"
+  else
+    echo "  - PATH already correct"
+  fi
 
-	#CLASSPATH
-	if [ `isinpath "$CLASSPATH" "$GSDL3HOME/WEB-INF/classes"` == "false" ]; then
-		CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
-		for JARFILE in $GSDL3SRCHOME/*.jar; do
-			CLASSPATH=$CLASSPATH:$JARFILE
-		done
-		for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
-			CLASSPATH=$CLASSPATH:$JARFILE
-		done
-		for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
-			CLASSPATH=$CLASSPATH:$JARFILE
-		done
-		for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
-			CLASSPATH=$CLASSPATH:$JARFILE
-		done    
-		for JARFILE in $GSDL3SRCHOME/build/*.jar; do
-			CLASSPATH=$CLASSPATH:$JARFILE
-		done
-		export CLASSPATH
-		echo "  - Adjusted CLASSPATH"
-	else
-		echo "  - CLASSPATH already correct"
-	fi
+  #CLASSPATH
+  if [ `isinpath "$CLASSPATH" "$GSDL3HOME/WEB-INF/classes"` == "false" ]; then
+    CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
+    for JARFILE in $GSDL3SRCHOME/*.jar; do
+      CLASSPATH=$CLASSPATH:$JARFILE
+    done
+    for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
+      CLASSPATH=$CLASSPATH:$JARFILE
+    done
+    for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
+      CLASSPATH=$CLASSPATH:$JARFILE
+    done
+    for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
+      CLASSPATH=$CLASSPATH:$JARFILE
+    done    
+    for JARFILE in $GSDL3SRCHOME/build/*.jar; do
+      CLASSPATH=$CLASSPATH:$JARFILE
+    done
+    export CLASSPATH
+    echo "  - Adjusted CLASSPATH"
+  else
+    echo "  - CLASSPATH already correct"
+  fi
 
-	#LD_LIBRARY_PATH
-	if [ `isinpath "$LD_LIBRARY_PATH" "$GSDL3SRCHOME/lib/jni"` == "false" ]; then
-		LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
-		export LD_LIBRARY_PATH
-		DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
-		export DYLD_LIBRARY_PATH
-		echo "  - Adjusted LD_LIBRARY_PATH"
-	else
-		echo "  - LD_LIBRARY_PATH already correct"
-	fi
+  #LD_LIBRARY_PATH
+  if [ `isinpath "$LD_LIBRARY_PATH" "$GSDL3SRCHOME/lib/jni"` == "false" ]; then
+    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
+    export LD_LIBRARY_PATH
+    DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
+    export DYLD_LIBRARY_PATH
+    echo "  - Adjusted LD_LIBRARY_PATH"
+  else
+    echo "  - LD_LIBRARY_PATH already correct"
+  fi
 
-	#ant
-	which ant &> /dev/null
-	if [ "$?" != "0" ]; then
-			ANT_HOME=$GSDL3SRCHOME/packages/ant
-			PATH=$ANT_HOME/bin:$PATH
-		echo "  - Setup ant"
-	else
-		echo "  - Ant already setup"
-	fi
+  #ant
+  which ant &> /dev/null
+  if [ "$?" != "0" ]; then
+      ANT_HOME=$GSDL3SRCHOME/packages/ant
+      PATH=$ANT_HOME/bin:$PATH
+    echo "  - Setup ant"
+  else
+    echo "  - Ant already setup"
+  fi
 
-	echo
+  echo
 }
 
 function checkJava() {
-	echo "Checking Java"
+  echo "Checking Java"
 
-  bin/search4j -m $java_min_version &> /dev/null
+  HINT=`pwd`/packages/jre
+  bin/search4j -p $HINT -m $java_min_version &> /dev/null
   if [ "$?" != "0" ]; then
 
-		#java is not set up already
-	  bin/search4j -m $java_min_version -h packages/jre &> /dev/null
-	  if [ "$?" == "0" ]; then
-			#bundled java exists, set up
-			export JAVA_HOME=`pwd`/packages/jre
-  		echo "  - Exported JAVA_HOME to point to bundled java"
-		else
-			#no java exists
-	  	echo "  - Failed to locate java ($java_min_version or greater)"
-			bin/search4j &> /dev/null; if [ "$?" == "0" ]; then echo "  (It looks like you hava java but it's too old)"; fi
-			echo "  - Please set JAVA_HOME or JRE_HOME to point to an appropriate java"
-  		echo "    And add JAVA_HOME/bin or JRE_HOME/bin to your PATH"
-		fi
+    #java is not set up already
+    FOUNDJAVAHOME=`bin/search4j -p $HINT -m $java_min_version`
+    if [ "$?" == "0" ]; then
+      #bundled java exists, set up
+      export JAVA_HOME=$FOUNDJAVAHOME
+      echo "  - Set (exported) JAVA_HOME to $FOUNDJAVAHOME"
+    else
+      #no java exists
+      echo "  - Failed to locate java ($java_min_version or greater)"
+      bin/search4j &> /dev/null; if [ "$?" == "0" ]; then echo "  (It looks like you hava java but it's too old)"; fi
+      echo "  - Please set JAVA_HOME or JRE_HOME to point to an appropriate java"
+      echo "    And add JAVA_HOME/bin or JRE_HOME/bin to your PATH"
+    fi
 
-	else
+  else
 
-		#java is already set up
-		echo "  - Found java at: `bin/search4j -m $java_min_version`"
+    #java is already set up
+    echo "  - Found java at: `bin/search4j -m $java_min_version`"
 
   fi
-	echo
+  echo
 }
 
@@ -157,11 +158,11 @@
 
 function isinpath() {
-	for file in `echo $1 | sed 's/:/ /g'`; do
-		if [ "$file" == "$2" ]; then
-			echo true
-			return
-		fi
-	done
-	echo false
+  for file in `echo $1 | sed 's/:/ /g'`; do
+    if [ "$file" == "$2" ]; then
+      echo true
+      return
+    fi
+  done
+  echo false
 }
 
