Changeset 17302


Ignore:
Timestamp:
2008-09-17T11:59:00+12:00 (16 years ago)
Author:
oranfry
Message:

added a priority hint option to search4j

Location:
release-kits/shared/search4j
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release-kits/shared/search4j/libsearch4j.cpp

    r15897 r17302  
    293293* return a Jvm object which represents the jvm on disk
    294294*/
    295 bool find( Jvm &jvm, bool use_minimum, Jvm minimum, string hint, bool verbose ) {
     295bool find( Jvm &jvm, bool use_minimum, Jvm minimum, string phint, string hint, bool verbose ) {
    296296   
    297297    if ( verbose ) cout << "Searching for a JVM" << endl;
     
    300300    bool jvmFound = false;
    301301   
     302    if ( !jvmFound ) {
     303       
     304        //try the priority hint
     305        if ( verbose ) cout << " - trying priority hint: ";
     306        if ( strcmp(phint.c_str(),"") != 0  ) {
     307            if ( verbose ) cout << "(" << phint << ") ";
     308            jvm.setJavaHome( phint );
     309            if ( jvm.check() ) {
     310                if ( use_minimum ) {
     311                    if ( jvm.compare( minimum ) >= 0 ) {
     312                        jvmFound = true;
     313                    }
     314                } else {
     315                    jvmFound = true;
     316                }
     317            }
     318        }
     319        if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; }
     320    }
     321
    302322    if ( !jvmFound ) {
    303323       
  • release-kits/shared/search4j/libsearch4j.h

    r15897 r17302  
    5353
    5454
    55 bool find( Jvm &jvm, bool use_minimum, Jvm minimum, string hint, bool verbose );
     55bool find( Jvm &jvm, bool use_minimum, Jvm minimum, string phint, string hint, bool verbose );
  • release-kits/shared/search4j/search4j.cpp

    r15892 r17302  
    4545
    4646    bool verbose = false;
     47    string phint = "";
    4748    string hint = "";
    4849    bool use_minimum = false;
     
    9495            }
    9596
     97        } else if ( strcmp(argv[i], "-p") == 0 ) {
     98            if ( i == argc-1 ) {
     99                usage();
     100                return -1;
     101            } else {
     102                phint = argv[++i];
     103            }
     104
    96105        } else if ( strcmp(argv[i], "-h") == 0 ) {
    97106            if ( i == argc-1 ) {
     
    120129    //find java
    121130    Jvm foundJvm;
    122     bool found = find( foundJvm, use_minimum, minimum, hint, verbose );
     131    bool found = find( foundJvm, use_minimum, minimum, phint, hint, verbose );
    123132
    124133    //check if it was found
     
    237246        << "Global Options:" << endl
    238247        << "          -m VERSION_STRING: (minimum) find a java of the given version or newer, or fail" << endl
     248        << "          -p LOCATION: (priority hint) first look for java in LOCATION (treated as a JAVA_HOME)" << endl
    239249        << "          -h LOCATION: (hint) as a last resort look for java in LOCATION (treated as a JAVA_HOME)" << endl
    240250        << "          -w: (windows) find and/or use the javaw.exe executable instead of java.exe (in windows only)" << endl
Note: See TracChangeset for help on using the changeset viewer.