I ended up having to create two separate scripts - one for each
version's environment requirements. I could not affect the classpath in
anyway that completely refreshed it. 

I did more searching and found that this is just not supported, and that
Patrick had asked for suggestions on some way to implement a method to
do this, or at least it appeard the problem (from 2003) was a difficult
one.

During my development and testing I found that depending on the way I
killed my script, the JVM it started was still running and that I had to
explicitly kill -9 the JVM process. So, I'm wondering, if the overhead
of starting a new JVM is not a concern for the user would it be easy to
have a RESTART option, or a KILL $pid? I suppose if 'use Inline::Java'
is loaded when perl starts this would not work.

Maybe some way to kill the JVM [by pid] and use require when a new JVM
was needed? 

Mike

-----Original Message-----
From: VANOLE, MICHAEL J (ATTSI) 
Sent: Monday, April 26, 2010 9:48 AM
To: inline@perl.org
Subject: Replacing CLASSPATH contents

Hi,

I'm using inline::java to run code for a version based product. I now
have a need to support two versions of the same code in the same script.
My problem is that the to versions conflict with each other. So, having
both versions specified in the same classpath causes each versions use
to break. If I use one version or the other I'm fine. 

Is there a way with inline::java to run two different environments? I am
using a shared environment, but I suppose I don't need to. 

CLASSPATH is currently set in the .profile for the user (unix) running
the process.

use Inline::Java qw(study_classes) ;
use Inline JAVA => 'STUDY', SHARED_JVM => 1, STUDY => [], DEBUG => 1; 

I tried this:

use Inline::Java qw(study_classes) ;
use Inline JAVA => 'STUDY', SHARED_JVM => 1, STUDY => [], DEBUG => 1,
CLASSPATH => $ENV{VERSION2CLASSES}; 

But I could not switch to $ENV{VERSION3CLASSES}

Tried this - didn't work:

sub sub1 {
        undef $ENV{CLASSPATH};
        $ENV{CLASSPATH} = $ENV{VERSION2CLASSES};
        do something inline'ish with version2
}

sub sub2 {
        undef $ENV{CLASSPATH};
        $ENV{CLASSPATH} = $ENV{VERSION3CLASSES};
        do something inline'ish with version3
}

Thank you in advance,
Mike

Reply via email to