[22529] | 1 | /*
|
---|
| 2 | * Library of functions for the Search4j utility
|
---|
| 3 | */
|
---|
| 4 |
|
---|
[15892] | 5 | #include "libsearch4j.h"
|
---|
[15690] | 6 |
|
---|
[15892] | 7 |
|
---|
[15690] | 8 | #ifdef WINDOWS
|
---|
| 9 | //minimal launch4j stuff
|
---|
[22529] | 10 | #define NO_JAVA_FOUND 0
|
---|
| 11 | #define FOUND_JRE 1
|
---|
| 12 | #define FOUND_SDK 2
|
---|
| 13 |
|
---|
[15690] | 14 | //windows functions
|
---|
[22529] | 15 | #define popen _popen
|
---|
[15690] | 16 | #define pclose _pclose
|
---|
| 17 | #define strcmp _stricmp
|
---|
[15892] | 18 |
|
---|
[15690] | 19 | #endif /* WINDOWS */
|
---|
[15892] | 20 |
|
---|
[22529] | 21 | void replace_all ( std::string & str, std::string const & pattern, std::string const & replacement ) {
|
---|
[15892] | 22 |
|
---|
[22529] | 23 | std::string::size_type start = str.find( pattern, 0 );
|
---|
| 24 |
|
---|
| 25 | while ( start != str.npos ) {
|
---|
| 26 | str.replace( start, pattern.size(), replacement );
|
---|
| 27 | start = str.find( pattern, start+replacement.size() );
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | int process( string command, bool render ) {
|
---|
| 34 |
|
---|
[15892] | 35 | #ifdef WINDOWS
|
---|
| 36 |
|
---|
[22529] | 37 | STARTUPINFO si;
|
---|
| 38 | PROCESS_INFORMATION pi;
|
---|
| 39 | memset(&pi, 0, sizeof(pi));
|
---|
| 40 | memset(&si, 0, sizeof(si));
|
---|
| 41 | si.cb = sizeof(si);
|
---|
[15892] | 42 |
|
---|
[22529] | 43 | DWORD dwExitCode = -1;
|
---|
| 44 | char* cmd = (char*)command.c_str();
|
---|
| 45 |
|
---|
| 46 | bool result;
|
---|
| 47 | if ( render ) {
|
---|
| 48 | result = CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
|
---|
| 49 | } else {
|
---|
| 50 | result = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | if ( result ) {
|
---|
| 54 | WaitForSingleObject(pi.hProcess, INFINITE);
|
---|
| 55 | GetExitCodeProcess(pi.hProcess, &dwExitCode);
|
---|
| 56 | CloseHandle(pi.hThread);
|
---|
| 57 | CloseHandle(pi.hProcess);
|
---|
| 58 | }
|
---|
| 59 | return dwExitCode;
|
---|
| 60 |
|
---|
[15892] | 61 | #else
|
---|
| 62 |
|
---|
| 63 | return system( command.c_str() );
|
---|
| 64 |
|
---|
| 65 | #endif
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 |
|
---|
[22529] | 70 | int process_and_catch_output( string command, string &output ) {
|
---|
| 71 |
|
---|
| 72 | FILE *pPipe;
|
---|
[15892] | 73 |
|
---|
| 74 | char cmd[1024];
|
---|
| 75 | strcpy(cmd, command.c_str());
|
---|
[22529] | 76 | strcat(cmd, " 2>&1" );
|
---|
[15892] | 77 |
|
---|
[22529] | 78 | //if ( verbose ) cout << "process(): running '" << command << "'" << endl;
|
---|
| 79 | #ifdef WINDOWS
|
---|
| 80 | if( (pPipe = _popen( cmd, "rt" )) == NULL ) {
|
---|
| 81 | _pclose( pPipe );
|
---|
| 82 | #else
|
---|
| 83 | if( (pPipe = popen( cmd, "r" )) == NULL ) {
|
---|
| 84 | pclose( pPipe );
|
---|
| 85 | #endif
|
---|
| 86 | return -1;
|
---|
[15690] | 87 | }
|
---|
[22529] | 88 | //if ( verbose ) cout << "started process" << endl;
|
---|
[15892] | 89 |
|
---|
[22529] | 90 | /* Read pipe until end of file. */
|
---|
| 91 | while( !feof( pPipe ) ) {
|
---|
| 92 | char psBuffer[128];
|
---|
| 93 | //if ( verbose ) cout << "get some data" << endl;
|
---|
| 94 | if( fgets( psBuffer, 128, pPipe ) != NULL ) {
|
---|
| 95 |
|
---|
| 96 | //if ( verbose ) cout << "got: " << psBuffer << endl;
|
---|
| 97 | output.append( psBuffer );
|
---|
| 98 |
|
---|
| 99 | } else {
|
---|
| 100 | //if ( verbose ) cout << "none left" << endl;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | }
|
---|
[15892] | 104 |
|
---|
[22529] | 105 | /* Close pipe and return return value of pPipe. */
|
---|
| 106 | #ifdef WINDOWS
|
---|
| 107 | int code = _pclose( pPipe );
|
---|
| 108 | #else
|
---|
| 109 | int code = pclose( pPipe );
|
---|
| 110 | #endif
|
---|
[15892] | 111 |
|
---|
[22529] | 112 | return code;
|
---|
| 113 |
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[15892] | 116 | //Jvm class methods
|
---|
[22529] | 117 |
|
---|
[20709] | 118 | Jvm::Jvm()
|
---|
| 119 | : era_(1), major_(0), minor_(0), update_(0),
|
---|
| 120 | javaHome_(),
|
---|
| 121 | isJdk_(false), healthy_(false)
|
---|
[22529] | 122 | {}
|
---|
[15892] | 123 |
|
---|
[20709] | 124 | Jvm::~Jvm()
|
---|
| 125 | {
|
---|
| 126 | // javaHome automatically destructed
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 |
|
---|
[22529] | 130 | void Jvm::setJavaHome( string jh ) {
|
---|
| 131 | healthy_ = true;
|
---|
| 132 | javaHome_ = jh;
|
---|
[18237] | 133 | setVersionFromExeOuput();
|
---|
[22529] | 134 | setIsJdkFromJavacPresence();
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | string Jvm::getJavaHome() {
|
---|
| 138 | return javaHome_;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | string Jvm::getExecutable() {
|
---|
| 142 | string exec = "";
|
---|
| 143 | exec.append( javaHome_ );
|
---|
[15892] | 144 |
|
---|
| 145 | #ifdef WINDOWS
|
---|
| 146 | exec.append( "\\bin\\java.exe" );
|
---|
| 147 | #endif
|
---|
| 148 |
|
---|
| 149 | #ifndef WINDOWS
|
---|
| 150 | exec.append( "/bin/java" );
|
---|
| 151 | #endif
|
---|
[22529] | 152 |
|
---|
| 153 | return exec;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | #ifdef WINDOWS
|
---|
| 157 | string Jvm::getWinExecutable() {
|
---|
| 158 | string exec = "";
|
---|
| 159 | exec.append( javaHome_ );
|
---|
| 160 | exec.append( "\\bin\\javaw.exe" );
|
---|
| 161 | return exec;
|
---|
| 162 | }
|
---|
| 163 | #endif
|
---|
| 164 |
|
---|
| 165 |
|
---|
| 166 | string Jvm::getVersion() {
|
---|
| 167 | stringstream ss;
|
---|
| 168 | ss << era_ << "." << major_ << "." << minor_ << "_" << update_;
|
---|
| 169 | return ss.str();
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | bool Jvm::check() {
|
---|
| 173 | return healthy_;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | bool Jvm::setVersionFromString( string version ) {
|
---|
| 177 | era_ = atoi( version.substr(0,1).c_str() );
|
---|
| 178 | major_ = atoi( version.substr(2,1).c_str() );
|
---|
[28699] | 179 | if(version.length() >= 5) {
|
---|
| 180 | minor_ = atoi( version.substr(4,1).c_str() );
|
---|
| 181 | } else {
|
---|
| 182 | minor_ = 0;
|
---|
| 183 | }
|
---|
| 184 | if(version.length() >= 7) {
|
---|
| 185 | update_ = atoi( version.substr(6,2).c_str() );
|
---|
| 186 | } else {
|
---|
| 187 | update_ = 0;
|
---|
| 188 | }
|
---|
[22529] | 189 | return true;
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | int Jvm::compare( Jvm otherJvm ) {
|
---|
| 193 | //era
|
---|
| 194 | if ( era_ > otherJvm.getEra() )
|
---|
| 195 | return 1;
|
---|
| 196 | else if ( era_ < otherJvm.getEra() )
|
---|
| 197 | return -1;
|
---|
| 198 |
|
---|
| 199 | //major
|
---|
| 200 | if ( major_ > otherJvm.getMajor() )
|
---|
| 201 | return 1;
|
---|
| 202 | else if ( major_ < otherJvm.getMajor() )
|
---|
| 203 | return -1;
|
---|
| 204 |
|
---|
| 205 | //minor
|
---|
| 206 | if ( minor_ > otherJvm.getMinor() )
|
---|
| 207 | return 1;
|
---|
| 208 | else if ( minor_ < otherJvm.getMinor() )
|
---|
| 209 | return -1;
|
---|
| 210 |
|
---|
| 211 | //update
|
---|
| 212 | if ( update_ > otherJvm.getUpdate() )
|
---|
| 213 | return 1;
|
---|
| 214 | else if ( update_ < otherJvm.getUpdate() )
|
---|
| 215 | return -1;
|
---|
| 216 |
|
---|
| 217 | //all the same so far, must be exactly the same
|
---|
| 218 | return 0;
|
---|
| 219 |
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | int Jvm::getEra() { return era_; }
|
---|
| 223 | int Jvm::getMajor() { return major_; }
|
---|
| 224 | int Jvm::getMinor() { return minor_; }
|
---|
[20709] | 225 | int Jvm::getUpdate() { return update_; }
|
---|
[18237] | 226 |
|
---|
[20709] | 227 | bool Jvm::getIsJdk() { return isJdk_; }
|
---|
[22529] | 228 | bool Jvm::getIsJre() { return !isJdk_; }
|
---|
| 229 |
|
---|
| 230 | void Jvm::setVersionFromExeOuput() {
|
---|
| 231 | string command = "", output = "";
|
---|
| 232 | command.append( "\"" );
|
---|
| 233 | command.append( getExecutable() );
|
---|
| 234 | command.append( "\"" );
|
---|
| 235 | command.append(" -version");
|
---|
| 236 |
|
---|
| 237 | //cerr << "command: " << command << endl;
|
---|
| 238 | int result = process_and_catch_output( command, output );
|
---|
| 239 | //cerr << "output: " << output << endl;
|
---|
| 240 |
|
---|
| 241 | if ( result == 0 ) {
|
---|
[30172] | 242 | // 22 is the length of sentinel string plus typical version value
|
---|
| 243 | int max_search_length = output.length() - 22;
|
---|
| 244 | int caret = 0;
|
---|
| 245 | bool found = false;
|
---|
| 246 | while (caret < max_search_length && !found) {
|
---|
[32880] | 247 | const int to_match_len = 8;
|
---|
| 248 | if ( strcmp( output.substr( caret, to_match_len ).c_str() , " version" ) == 0 ) {
|
---|
| 249 | era_ = atoi( output.substr(caret + to_match_len + 2,1).c_str() );
|
---|
| 250 | major_ = atoi( output.substr(caret + to_match_len + 4,1).c_str() );
|
---|
| 251 | minor_ = atoi( output.substr(caret + to_match_len + 6,1).c_str() );
|
---|
| 252 | update_ = atoi( output.substr(caret + to_match_len + 8,2).c_str() );
|
---|
[30172] | 253 | found = true;
|
---|
| 254 | }
|
---|
| 255 | else {
|
---|
| 256 | caret++;
|
---|
| 257 | }
|
---|
| 258 | }
|
---|
| 259 | if (!found) {
|
---|
| 260 | healthy_ = false;
|
---|
| 261 | }
|
---|
[22529] | 262 | }
|
---|
[30172] | 263 | else {
|
---|
| 264 | healthy_ = false;
|
---|
| 265 | }
|
---|
[22529] | 266 | }
|
---|
[18237] | 267 | void Jvm::setIsJdkFromJavacPresence() {
|
---|
[22529] | 268 | string javacFile = "";
|
---|
[20709] | 269 | javacFile.append( javaHome_ );
|
---|
[18237] | 270 |
|
---|
| 271 | #ifdef WINDOWS
|
---|
| 272 | javacFile.append( "\\bin\\javac.exe" );
|
---|
| 273 | #endif
|
---|
| 274 | #ifndef WINDOWS
|
---|
| 275 | javacFile.append( "/bin/javac" );
|
---|
| 276 | #endif
|
---|
| 277 | struct stat stFileInfo;
|
---|
[20709] | 278 | isJdk_ = ( stat(javacFile.c_str(),&stFileInfo) == 0 );
|
---|
[18237] | 279 | }
|
---|
[22529] | 280 |
|
---|
[15892] | 281 | //end of Jvm class methods
|
---|
| 282 |
|
---|
[22529] | 283 |
|
---|
| 284 | #ifdef WINDOWS
|
---|
| 285 | int regSearch(HKEY hKey, const char* keyName, int searchType, char* foundJavaVer ) {
|
---|
| 286 | DWORD x = 0;
|
---|
| 287 | unsigned long size = 1024;
|
---|
| 288 | FILETIME time;
|
---|
| 289 | char buffer[1024] = {0};
|
---|
| 290 |
|
---|
| 291 | int foundJava = NO_JAVA_FOUND;
|
---|
| 292 |
|
---|
| 293 | while (RegEnumKeyEx(
|
---|
| 294 | hKey, // handle to key to enumerate
|
---|
| 295 | x++, // index of subkey to enumerate
|
---|
| 296 | buffer, // address of buffer for subkey name
|
---|
| 297 | &size, // address for size of subkey buffer
|
---|
| 298 | NULL, // reserved
|
---|
| 299 | NULL, // address of buffer for class string
|
---|
| 300 | NULL, // address for size of class buffer
|
---|
| 301 | &time) == ERROR_SUCCESS) {
|
---|
| 302 | strcpy(foundJavaVer, buffer);
|
---|
| 303 | foundJava = searchType;
|
---|
| 304 | size = 1024;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | return foundJava;
|
---|
| 308 |
|
---|
| 309 | }
|
---|
| 310 | #endif
|
---|
| 311 |
|
---|
| 312 | /*
|
---|
| 313 | * function to find java
|
---|
| 314 | * implements the logic drawn on the dl lab whiteboard in feb 08
|
---|
| 315 | * return a Jvm object which represents the jvm on disk
|
---|
| 316 | */
|
---|
| 317 | bool find( Jvm &jvm, bool use_minimum, const Jvm& minimum, bool jreOnly, bool jdkOnly, string phint, string hint, bool verbose ) {
|
---|
| 318 |
|
---|
| 319 | if ( verbose ) cout << "Searching for a JVM" << endl;
|
---|
| 320 |
|
---|
[32880] | 321 | char *javaHomeEnv = NULL;
|
---|
[22529] | 322 | bool jvmFound = false;
|
---|
| 323 |
|
---|
| 324 | if ( !jvmFound ) {
|
---|
| 325 |
|
---|
| 326 | //try the priority hint
|
---|
| 327 | if ( verbose ) cout << " - trying priority hint: ";
|
---|
| 328 | if ( strcmp(phint.c_str(),"") != 0 ) {
|
---|
| 329 | if ( verbose ) cout << "(" << phint << ") ";
|
---|
| 330 | jvm.setJavaHome( phint );
|
---|
| 331 | if ( jvm.check() ) {
|
---|
| 332 | if ( use_minimum ) {
|
---|
| 333 | if ( jvm.compare( minimum ) >= 0 ) {
|
---|
| 334 | jvmFound = true;
|
---|
| 335 | }
|
---|
| 336 | } else {
|
---|
| 337 | jvmFound = true;
|
---|
| 338 | }
|
---|
[18237] | 339 | }
|
---|
| 340 | if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
|
---|
| 341 | jvmFound = false;
|
---|
[22529] | 342 | }
|
---|
[18237] | 343 |
|
---|
[22529] | 344 | }
|
---|
| 345 | if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | if ( !jvmFound ) {
|
---|
| 349 |
|
---|
| 350 | //try JAVA_HOME
|
---|
| 351 | if ( verbose ) cout << " - trying JAVA_HOME: ";
|
---|
[20709] | 352 | javaHomeEnv = getenv( "JAVA_HOME" );
|
---|
[22529] | 353 | if ( javaHomeEnv != NULL ) {
|
---|
[20709] | 354 | if ( verbose ) cout << "(" << javaHomeEnv << ") ";
|
---|
[22529] | 355 | jvm.setJavaHome( javaHomeEnv );
|
---|
| 356 | if ( jvm.check() ) {
|
---|
| 357 | if ( use_minimum ) {
|
---|
| 358 | if ( jvm.compare( minimum ) >= 0 ) {
|
---|
| 359 | jvmFound = true;
|
---|
| 360 | }
|
---|
| 361 | } else {
|
---|
| 362 | jvmFound = true;
|
---|
| 363 | }
|
---|
[18237] | 364 | }
|
---|
| 365 | if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
|
---|
| 366 | jvmFound = false;
|
---|
[22529] | 367 | }
|
---|
| 368 |
|
---|
| 369 | }
|
---|
| 370 | if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | if ( !jvmFound ) {
|
---|
| 374 |
|
---|
| 375 | //try JRE_HOME
|
---|
| 376 | if ( verbose ) cout << " - trying JRE_HOME: ";
|
---|
| 377 | javaHomeEnv = getenv( "JRE_HOME" );
|
---|
| 378 | if ( javaHomeEnv != NULL ) {
|
---|
[20709] | 379 | if ( verbose ) cout << "(" << javaHomeEnv << ") ";
|
---|
[22529] | 380 | jvm.setJavaHome( javaHomeEnv );
|
---|
| 381 | if ( jvm.check() ) {
|
---|
| 382 | if ( use_minimum ) {
|
---|
| 383 | if ( jvm.compare( minimum ) >= 0 ) {
|
---|
| 384 | jvmFound = true;
|
---|
| 385 | }
|
---|
| 386 | } else {
|
---|
| 387 | jvmFound = true;
|
---|
| 388 | }
|
---|
[18237] | 389 | }
|
---|
| 390 | if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
|
---|
| 391 | jvmFound = false;
|
---|
[22529] | 392 | }
|
---|
[15690] | 393 |
|
---|
[22529] | 394 | }
|
---|
| 395 | if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | #ifdef WINDOWS
|
---|
| 399 | if ( !jvmFound ) {
|
---|
| 400 |
|
---|
| 401 | //try the registry - this code based on launch4j code
|
---|
| 402 | char foundJavaVer[8192] = {0};
|
---|
| 403 | int foundJava = NO_JAVA_FOUND;
|
---|
| 404 |
|
---|
| 405 | if ( verbose ) cout << " - trying the registry: "; cout.flush();
|
---|
| 406 | HKEY hKey;
|
---|
| 407 | const char jre[] = "SOFTWARE\\JavaSoft\\Java Runtime Environment";
|
---|
| 408 | const char sdk[] = "SOFTWARE\\JavaSoft\\Java Development Kit";
|
---|
| 409 |
|
---|
| 410 | if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(jre), 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey) == ERROR_SUCCESS ) {
|
---|
| 411 | foundJava = regSearch(hKey, jre, FOUND_JRE, foundJavaVer);
|
---|
| 412 | RegCloseKey(hKey);
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 | if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(sdk), 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey) == ERROR_SUCCESS ) {
|
---|
| 416 | foundJava = regSearch(hKey, sdk, FOUND_SDK, foundJavaVer);
|
---|
| 417 | RegCloseKey(hKey);
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | if ( foundJava != NO_JAVA_FOUND ) {
|
---|
| 421 | char path[1024] = {0};
|
---|
| 422 | char keyBuffer[1024];
|
---|
| 423 | unsigned long datatype;
|
---|
| 424 | unsigned long bufferlength = 1024;
|
---|
| 425 | if (foundJava == FOUND_JRE) {
|
---|
| 426 | strcpy(keyBuffer, jre);
|
---|
| 427 | } else {
|
---|
| 428 | strcpy(keyBuffer, sdk);
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | strcat(keyBuffer, "\\");
|
---|
| 432 | strcat(keyBuffer, foundJavaVer);
|
---|
| 433 |
|
---|
| 434 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(keyBuffer), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
|
---|
| 435 | unsigned char buffer[1024] = {0};
|
---|
| 436 | if (RegQueryValueEx(hKey, "JavaHome", NULL, &datatype, buffer, &bufferlength) == ERROR_SUCCESS) {
|
---|
| 437 | int i = 0;
|
---|
| 438 | do {
|
---|
| 439 | path[i] = buffer[i];
|
---|
| 440 | } while (path[i++] != 0);
|
---|
| 441 | if (foundJava == FOUND_SDK) {
|
---|
| 442 | strcat(path, "\\jre");
|
---|
[18237] | 443 | }
|
---|
[22529] | 444 | if ( verbose ) cerr << "path: " << path << endl ;
|
---|
| 445 | jvm.setJavaHome( path );
|
---|
| 446 | if ( jvm.check() ) {
|
---|
| 447 | if ( use_minimum ) {
|
---|
| 448 | if ( jvm.compare( minimum ) >= 0 ) {
|
---|
| 449 | jvmFound = true;
|
---|
| 450 | }
|
---|
| 451 | } else {
|
---|
| 452 | jvmFound = true;
|
---|
| 453 | }
|
---|
| 454 | }
|
---|
[18237] | 455 | if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
|
---|
| 456 | jvmFound = false;
|
---|
[22529] | 457 | }
|
---|
| 458 | }
|
---|
| 459 | RegCloseKey(hKey);
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
| 462 | if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
|
---|
| 463 | }
|
---|
[15690] | 464 | #endif
|
---|
| 465 |
|
---|
[22529] | 466 | if ( !jvmFound ) {
|
---|
| 467 |
|
---|
| 468 | //try the hint
|
---|
| 469 | if ( verbose ) cout << " - trying hint: ";
|
---|
| 470 | if ( strcmp(hint.c_str(),"") != 0 ) {
|
---|
[15690] | 471 | if ( verbose ) cout << "(" << hint << ") ";
|
---|
[22529] | 472 | jvm.setJavaHome( hint );
|
---|
| 473 | if ( jvm.check() ) {
|
---|
| 474 | if ( use_minimum ) {
|
---|
| 475 | if ( jvm.compare( minimum ) >= 0 ) {
|
---|
| 476 | jvmFound = true;
|
---|
| 477 | }
|
---|
| 478 | } else {
|
---|
| 479 | jvmFound = true;
|
---|
| 480 | }
|
---|
[18237] | 481 | }
|
---|
| 482 | if ( (jreOnly && !jvm.getIsJre() ) || (jdkOnly && !jvm.getIsJdk()) ) {
|
---|
| 483 | jvmFound = false;
|
---|
[22529] | 484 | }
|
---|
[15690] | 485 |
|
---|
[22529] | 486 | }
|
---|
| 487 | if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
|
---|
| 488 | }
|
---|
| 489 |
|
---|
| 490 |
|
---|
| 491 | return jvmFound;
|
---|
| 492 | }
|
---|