Changeset 7234


Ignore:
Timestamp:
11/23/10 10:19:41 (10 years ago)
Author:
hinerm
Message:

Updated the bf-itk plug-in so that it no longer tries to instantiate a JVM if a JVM already exists, as this was causing issues on 64-bit unbuntu. - Mark

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/native/bf-itk/itkBioFormatsImageIO.cxx

    r7221 r7234  
    8282 
    8383    try { 
    84       // initialize the Java virtual machine 
    85       itkDebugMacro("Creating JVM..."); 
    86       jace::StaticVmLoader loader(JNI_VERSION_1_4); 
    87       jace::OptionList list; 
    88  
    89       const char name[] = "ITK_AUTOLOAD_PATH"; 
    90       const char* namePtr; 
    91       namePtr = name; 
    92       char* path; 
    93       path = getenv(name); 
    94       std::string dir(""); 
    95       if( path != NULL) { 
    96         dir.assign(path); 
    97       } 
    98  
    99       if( dir.at(dir.length() - 1) != '/' ) { 
    100         dir.append(1,'/'); 
    101       } 
    102  
    103       list.push_back(jace::ClassPath( 
    104  
    105  // To solve issue where JARs must live in current working directory: 
    106  // somehow discover my own origin directory 
    107  // e.g.: I am part of libBioFormatsIOPlugin.dylib 
    108  // and I live in folder: 
    109  //   /Users/hinerm/loci/bioformats/components/native/bf-itk/build/dist/bf-itk 
    110  // so, we want a string variable "dir" containing that folder name. 
    111  // Then, can pass classpath elements with that prefix. 
    112  //        dir+"jace-runtime.jar:"+dir+"bio-formats.jar:"+dir+"loci_tools.jar" 
    113       dir+"jace-runtime.jar:"+dir+"bio-formats.jar:"+dir+"loci_tools.jar" 
    114       )); 
    115       list.push_back(jace::CustomOption("-Xcheck:jni")); 
    116       list.push_back(jace::CustomOption("-Xmx256m")); 
    117       list.push_back(jace::CustomOption("-Djava.awt.headless=true")); 
    118       //list.push_back(jace::CustomOption("-verbose")); 
    119       //list.push_back(jace::CustomOption("-verbose:jni")); 
    120       jace::helper::createVm(loader, list, false); 
    121       itkDebugMacro("JVM created."); 
     84      jace::StaticVmLoader* tmpLoader = (jace::StaticVmLoader*)jace::helper::getVmLoader(); 
     85      if(tmpLoader == NULL) { 
     86 
     87        // initialize the Java virtual machine 
     88        itkDebugMacro("Creating JVM..."); 
     89        jace::OptionList list; 
     90        jace::StaticVmLoader loader(JNI_VERSION_1_4); 
     91 
     92        const char name[] = "ITK_AUTOLOAD_PATH"; 
     93        const char* namePtr; 
     94        namePtr = name; 
     95        char* path; 
     96        path = getenv(name); 
     97        std::string dir(""); 
     98        if( path != NULL) { 
     99          dir.assign(path); 
     100              } 
     101 
     102        if( dir.at(dir.length() - 1) != '/' ) { 
     103          dir.append(1,'/'); 
     104         
     105 
     106        list.push_back(jace::ClassPath( 
     107        dir+"jace-runtime.jar:"+dir+"bio-formats.jar:"+dir+"loci_tools.jar" 
     108        )); 
     109        list.push_back(jace::CustomOption("-Xcheck:jni")); 
     110        list.push_back(jace::CustomOption("-Xmx256m")); 
     111        list.push_back(jace::CustomOption("-Djava.awt.headless=true")); 
     112        //list.push_back(jace::CustomOption("-verbose")); 
     113        //list.push_back(jace::CustomOption("-verbose:jni")); 
     114        jace::helper::createVm(loader, list, false); 
     115        itkDebugMacro("JVM created."); 
     116      } 
    122117    } 
    123118    catch (JNIException& jniException) { 
Note: See TracChangeset for help on using the changeset viewer.