Ignore:
Timestamp:
2014-04-16T17:33:23+12:00 (10 years ago)
Author:
ak19
Message:

GTI on nzdl needs path to java executable. Since a custom javahome property can be set in gsdlsite.cfg, this is now read in if site from gsdlsite.cfg by common-src's gsdlsitecfg.cpp and set as an env var with putenv(), following Dr Bainbridge's idea. This env var is then read back in using getenv in gtiaction.cpp, so that it can run the appropriate java.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp

    r28973 r28979  
    8787  text_t set_gsdlos = "GSDLOS=";
    8888
    89   // path to java executable.
    90 
    91   if(java.empty()) {
     89  // Path to java executable. If javahome property was set in gsdlsite.cfg,
     90  // then common-src/src/lib/gsdlsite.cfg would have read this in and set it in the env
     91  // If the env var is empty, default to trying to use just "java"
     92  char* existing_javahome = getenv("JAVA_HOME"); // return value may not be modified by the program
     93
     94  if(existing_javahome == NULL) {
    9295    //java = "$JAVA_HOME/bin/java"; // doesn't work
    93     //java = "/research/root/jdk1.6.0_27/bin/java"; // can hardcode it, which may be necessary on nzdl or if default java is no longer version 6
    94     java = "java";
    95   }
     96    java = "java"; // works locally, but not on nzdl. On nzdl need to set javahome in gsdlsite.cfg
     97  } else {   
     98    java = existing_javahome;
     99    java += "/bin/java";
     100  }
    96101
    97102#if defined (__WIN32__)
     
    655660    //gti_arguments = "get-first-n-chunks-requiring-work " + target_language_code + " " + translation_file_key + " " + "10000" + " | /opt/jdk1.6.0/bin/java -cp /home/nzdl/gti:/home/nzdl/gti/xalan.jar ApplyXSLT /home/nzdl/gti/gti-generate-excel-xml.xsl -";
    656661
    657     //gti_arguments = "get-first-n-chunks-requiring-work " + target_language_code + " " + translation_file_key + " " + "10000" + " | /research/root/jdk1.6.0_27/bin/java -cp /research/ak19/gs2-svn-gti:/research/ak19/gs2-svn-gti/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -c -t /research/ak19/gs2-svn-gti/bin/script/gti-generate-excel-xml.xsl";
    658 
    659     // don't need to add toplevel gsdlhome to classpath actually, as the following will work from the commandline:
    660     // gti.pl get-all-chunks nl coredm | java -cp /research/ak19/gs2-svn-gti/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -t /research/ak19/gs2-svn-gti/bin/script/gti-generate-excel-xml.xsl
     662    // don't actually need to add toplevel gsdlhome to classpath
    661663    gti_arguments = "get-first-n-chunks-requiring-work " + target_language_code + " " + translation_file_key + " " + "10000" + " | " + java + " -cp " + gsdlhome + path_separator + gsdlhome + "/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -c -t " + gsdlhome + "/bin/script/gti-generate-excel-xml.xsl";
    662664
     
    664666    //gti_arguments = "get-all-chunks " + target_language_code + " " + translation_file_key + " | /opt/jdk1.6.0/bin/java -cp /home/nzdl/gti:/home/nzdl/gti/xalan.jar ApplyXSLT /home/nzdl/gti/gti-generate-excel-xml.xsl -";
    665667
    666     //gti_arguments = "get-all-chunks " + target_language_code + " " + translation_file_key + " | /research/root/jdk1.6.0_27/bin/java -cp /research/ak19/gs2-svn-gti/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -c -t /research/ak19/gs2-svn-gti/bin/script/gti-generate-excel-xml.xsl";
    667 
    668     // don't need to add toplevel gsdlhome to classpath actually, as the following will work from the commandline:
    669     // gti.pl get-all-chunks nl coredm | java -cp /research/ak19/gs2-svn-gti/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -t /research/ak19/gs2-svn-gti/bin/script/gti-generate-excel-xml.xsl
     668    // don't actually need to add toplevel gsdlhome to classpath
    670669    gti_arguments = "get-all-chunks " + target_language_code + " " + translation_file_key + " | " + java +  " -cp " + gsdlhome + path_separator + gsdlhome + "/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -c -t " + gsdlhome + "/bin/script/gti-generate-excel-xml.xsl";
    671670  }
    672  
     671
    673672  text_t gti_response_xml_text = do_gti_request(gti_arguments, logout); 
    674673  if (gti_response_xml_text == "") {
Note: See TracChangeset for help on using the changeset viewer.