Changeset 18237 for other-projects/trunk/search4j/search4j.cpp
- Timestamp:
- 2008-12-17T17:38:47+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/search4j/search4j.cpp
r17302 r18237 18 18 JavaHome, 19 19 Version, 20 Executable 20 Executable, 21 Type 21 22 }; 22 23 … … 38 39 else if ( jp == Executable ) 39 40 return "Executable"; 41 else if ( jp == Type ) 42 return "Type"; 43 40 44 return "Unknown"; 41 45 } … … 49 53 bool use_minimum = false; 50 54 bool useJavaw = false; 51 Jvm minimum; 55 bool jdkOnly = false; 56 bool jreOnly = false; 57 Jvm minimum; 52 58 JvmProperty jvmProperty = JavaHome; 53 59 Action action = Find; … … 56 62 //parse commandline arguments 57 63 for (int i=1; i<argc; i++) { 64 65 //be verbose 58 66 if ( strcmp(argv[i], "--verbose") == 0 ) { 59 67 verbose = true; 68 69 //show help 60 70 } else if ( strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 ) { 61 71 usage(); 62 72 return 0; 73 74 //show version 63 75 } else if ( strcmp(argv[i], "-v") == 0 ) { 64 76 jvmProperty = Version; 77 78 //show path to executable 65 79 } else if ( strcmp(argv[i], "-e") == 0 ) { 66 80 jvmProperty = Executable; 81 82 //show whether jre or jdk 83 } else if ( strcmp(argv[i], "-t") == 0 ) { 84 jvmProperty = Type; 85 86 //compare found java with the given version string 67 87 } else if ( strcmp(argv[i], "-c") == 0 ) { 68 88 action = Compare; … … 74 94 } 75 95 96 //find only javas at or above the given version 76 97 } else if ( strcmp(argv[i], "-m") == 0 ) { 77 98 if ( i == argc-1 ) { … … 86 107 } 87 108 109 //find only jdks 110 } else if ( strcmp(argv[i], "-d") == 0 ) { 111 jdkOnly = true; 112 113 //find only jres 114 } else if ( strcmp(argv[i], "-r") == 0 ) { 115 jreOnly = true; 116 117 //launch the named jar with the found java 88 118 } else if ( strcmp(argv[i], "-l") == 0 ) { 89 119 if ( i == argc-1 ) { … … 95 125 } 96 126 127 //take the given priority hint 97 128 } else if ( strcmp(argv[i], "-p") == 0 ) { 98 129 if ( i == argc-1 ) { … … 103 134 } 104 135 136 // take the following hint 105 137 } else if ( strcmp(argv[i], "-h") == 0 ) { 106 138 if ( i == argc-1 ) { … … 110 142 hint = argv[++i]; 111 143 } 112 144 113 145 #ifdef WINDOWS 146 //show the path to the javaw executable 114 147 } else if ( strcmp(argv[i], "-w") == 0 ) { 115 148 useJavaw = true; … … 129 162 //find java 130 163 Jvm foundJvm; 131 bool found = find( foundJvm, use_minimum, minimum, phint, hint, verbose );164 bool found = find( foundJvm, use_minimum, minimum, jreOnly, jdkOnly, phint, hint, verbose ); 132 165 133 166 //check if it was found … … 145 178 if ( action == Find ) { 146 179 147 if ( verbose ) cout << "Property to print: " << jvmPropertyToString( jvmProperty ) << endl; 180 if ( verbose ) cout << "Property to print: " << jvmPropertyToString( jvmProperty ) << endl; 148 181 149 182 //found - print out info about it … … 162 195 cout << foundJvm.getExecutable() << endl; 163 196 #endif 197 } else if ( jvmProperty == Type ) { 198 if ( foundJvm.getIsJdk() ) { 199 cout << "JDK" << endl; 200 } else { 201 cout << "JRE" << endl; 202 } 164 203 } else { 165 204 return -1; //should never happen … … 221 260 << "find: find java and print out information about it" << endl 222 261 << endl 223 << " search4j [-v|-e ]" << endl262 << " search4j [-v|-e|-t]" << endl 224 263 << " eg: search4j -e" << endl 225 264 << endl … … 227 266 << " if -v is specified, print the java version string. E.g. 1.5.0_15, or" << endl 228 267 << " 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 268 << " if -t is specified, print whether the found java is a JRE or a JDK" << endl 229 269 << endl 230 270 << "compare: compare the found java with the given java version string" << endl … … 246 286 << "Global Options:" << endl 247 287 << " -m VERSION_STRING: (minimum) find a java of the given version or newer, or fail" << endl 288 << " -d : find only jdks" << endl 289 << " -r : find only jres" << endl 248 290 << " -p LOCATION: (priority hint) first look for java in LOCATION (treated as a JAVA_HOME)" << endl 249 291 << " -h LOCATION: (hint) as a last resort look for java in LOCATION (treated as a JAVA_HOME)" << endl
Note:
See TracChangeset
for help on using the changeset viewer.