Index: /other-projects/trunk/search4j/libsearch4j.cpp
===================================================================
--- /other-projects/trunk/search4j/libsearch4j.cpp	(revision 18236)
+++ /other-projects/trunk/search4j/libsearch4j.cpp	(revision 18237)
@@ -131,5 +131,4 @@
 	/* Close pipe and return return value of pPipe. */
 	int code = pclose( pPipe );
-
 	return code;
 
@@ -148,4 +147,5 @@
 	javaHome = jh;
 	setVersionFromExeOuput();
+	setIsJdkFromJavacPresence();
 }
 
@@ -231,4 +231,7 @@
 int Jvm::getMinor() { return minor; }
 int Jvm::getUpdate() { return update; }
+
+bool Jvm::getIsJdk() { return isJdk; }
+bool Jvm::getIsJre() { return !isJdk; }
 
 void Jvm::setVersionFromExeOuput() {
@@ -256,5 +259,18 @@
 	}
 }
-	
+void Jvm::setIsJdkFromJavacPresence() {
+	string javacFile = "";
+	javacFile.append( javaHome );
+
+	#ifdef WINDOWS
+	javacFile.append( "\\bin\\javac.exe" );
+	#endif
+	#ifndef WINDOWS
+	javacFile.append( "/bin/javac" );
+	#endif
+	struct stat stFileInfo;
+	isJdk = ( stat(javacFile.c_str(),&stFileInfo) == 0 );
+}
+
 //end of Jvm class methods
 
@@ -293,5 +309,5 @@
 * return a Jvm object which represents the jvm on disk
 */
-bool find( Jvm &jvm, bool use_minimum, Jvm minimum, string phint, string hint, bool verbose ) {
+bool find( Jvm &jvm, bool use_minimum, Jvm minimum, bool jreOnly, bool jdkOnly, string phint, string hint, bool verbose ) {
 	
 	if ( verbose ) cout << "Searching for a JVM" << endl;
@@ -316,4 +332,8 @@
 				}
 			}
+			if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
+				jvmFound = false;
+			}
+
 		}
 		if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
@@ -337,4 +357,8 @@
 				}
 			}
+			if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
+				jvmFound = false;
+			}
+
 		}
 		if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
@@ -358,4 +382,8 @@
 				}
 			}
+			if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
+				jvmFound = false;
+			}
+
 		}
 		if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
@@ -419,4 +447,7 @@
 						}
 					}
+					if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
+						jvmFound = false;
+					}
 				}
 				RegCloseKey(hKey);
@@ -443,4 +474,8 @@
 				}
 			}
+			if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
+				jvmFound = false;
+			}
+
 		}
 		if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
Index: /other-projects/trunk/search4j/libsearch4j.h
===================================================================
--- /other-projects/trunk/search4j/libsearch4j.h	(revision 18236)
+++ /other-projects/trunk/search4j/libsearch4j.h	(revision 18237)
@@ -3,4 +3,5 @@
 #include <string>
 #include <sstream>
+#include <sys/stat.h>
 using namespace std;
 #ifdef WINDOWS
@@ -27,5 +28,5 @@
 	string javaHome;
 	bool isJdk;
-	bool healthy;	
+	bool healthy;
 
 	public:
@@ -46,6 +47,10 @@
 	int getUpdate();
 
+	bool getIsJre();
+	bool getIsJdk();
+
 	private:
 	void setVersionFromExeOuput();
+	void setIsJdkFromJavacPresence();
 
 };
@@ -53,3 +58,3 @@
 
 
-bool find( Jvm &jvm, bool use_minimum, Jvm minimum, string phint, string hint, bool verbose );
+bool find( Jvm &jvm, bool use_minimum, Jvm minimum, bool jreOnly, bool jdeOnly, string phint, string hint, bool verbose );
Index: /other-projects/trunk/search4j/search4j.cpp
===================================================================
--- /other-projects/trunk/search4j/search4j.cpp	(revision 18236)
+++ /other-projects/trunk/search4j/search4j.cpp	(revision 18237)
@@ -18,5 +18,6 @@
 	JavaHome,
 	Version,
-	Executable
+	Executable,
+	Type
 };
 
@@ -38,4 +39,7 @@
 	else if ( jp == Executable )
 		return "Executable";
+	else if ( jp == Type )
+		return "Type";
+
 	return "Unknown";
 }
@@ -49,5 +53,7 @@
 	bool use_minimum = false;
 	bool useJavaw = false;
-	Jvm minimum; 
+	bool jdkOnly = false;
+	bool jreOnly = false;
+	Jvm minimum;
 	JvmProperty jvmProperty = JavaHome;
 	Action action = Find;
@@ -56,13 +62,27 @@
 	//parse commandline arguments
 	for (int i=1; i<argc; i++) {
+
+		//be verbose
 		if ( strcmp(argv[i], "--verbose") == 0 ) {
 			verbose = true;
+
+		//show help
 		} else if ( strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 ) {
 			usage();
 			return 0;
+
+		//show version
 		} else if ( strcmp(argv[i], "-v") == 0 ) {
 			jvmProperty = Version;
+
+		//show path to executable
 		} else if ( strcmp(argv[i], "-e") == 0 ) {
 			jvmProperty = Executable;
+
+		//show whether jre or jdk
+		} else if ( strcmp(argv[i], "-t") == 0 ) {
+			jvmProperty = Type;
+
+		//compare found java with the given version string
 		} else if ( strcmp(argv[i], "-c") == 0 ) {
 			action = Compare;
@@ -74,4 +94,5 @@
 			}
 
+		//find only javas at or above the given version
 		} else if ( strcmp(argv[i], "-m") == 0 ) {
 			if ( i == argc-1 ) {
@@ -86,4 +107,13 @@
 			}
 
+		//find only jdks
+		} else if ( strcmp(argv[i], "-d") == 0 ) {
+			jdkOnly = true;
+
+		//find only jres
+		} else if ( strcmp(argv[i], "-r") == 0 ) {
+			jreOnly = true;
+
+		//launch the named jar with the found java
 		} else if ( strcmp(argv[i], "-l") == 0 ) {
 			if ( i == argc-1 ) {
@@ -95,4 +125,5 @@
 			}
 
+		//take the given priority hint
 		} else if ( strcmp(argv[i], "-p") == 0 ) {
 			if ( i == argc-1 ) {
@@ -103,4 +134,5 @@
 			}
 
+		// take the following hint
 		} else if ( strcmp(argv[i], "-h") == 0 ) {
 			if ( i == argc-1 ) {
@@ -110,6 +142,7 @@
 				hint = argv[++i];
 			}
-			
+
 		#ifdef WINDOWS
+		//show the path to the javaw executable
 		} else if ( strcmp(argv[i], "-w") == 0 ) {
 			useJavaw = true;
@@ -129,5 +162,5 @@
 	//find java
 	Jvm foundJvm;
-	bool found = find( foundJvm, use_minimum, minimum, phint, hint, verbose );
+	bool found = find( foundJvm, use_minimum, minimum, jreOnly, jdkOnly, phint, hint, verbose );
 
 	//check if it was found
@@ -145,5 +178,5 @@
 	if ( action == Find ) {
 
-		if ( verbose ) cout << "Property to print: " << jvmPropertyToString( jvmProperty ) << endl;		
+		if ( verbose ) cout << "Property to print: " << jvmPropertyToString( jvmProperty ) << endl;
 
 		//found - print out info about it
@@ -162,4 +195,10 @@
 			cout << foundJvm.getExecutable() << endl;
 			#endif
+		} else if ( jvmProperty == Type ) {
+			if ( foundJvm.getIsJdk() ) {
+        cout << "JDK" << endl;
+			} else {
+	      cout << "JRE" << endl;
+			}
 		} else {
 			return -1; //should never happen
@@ -221,5 +260,5 @@
 		<< "find:     find java and print out information about it" << endl
 		<< endl
-		<< "          search4j [-v|-e]" << endl
+		<< "          search4j [-v|-e|-t]" << endl
 		<< "          eg: search4j -e" << endl
 		<< endl
@@ -227,4 +266,5 @@
 		<< "          if -v is specified, print the java version string. E.g. 1.5.0_15, or" << endl
 		<< "          if -e is specified, print the path the to the java executable. E.g. C:\\Program Files\\jre1.5.0_15\\bin\\java.exe" << endl
+		<< "          if -t is specified, print whether the found java is a JRE or a JDK" << endl
 		<< endl
 		<< "compare:  compare the found java with the given java version string" << endl
@@ -246,4 +286,6 @@
 		<< "Global Options:" << endl
 		<< "          -m VERSION_STRING: (minimum) find a java of the given version or newer, or fail" << endl
+		<< "          -d : find only jdks" << endl
+		<< "          -r : find only jres" << endl
 		<< "          -p LOCATION: (priority hint) first look for java in LOCATION (treated as a JAVA_HOME)" << endl
 		<< "          -h LOCATION: (hint) as a last resort look for java in LOCATION (treated as a JAVA_HOME)" << endl
