Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am having problem in setting CLASSPATH variable through my perl script such that it will work both on Windows and Solaris. On Solaris I can use export CLASSPATH=/mypath/ and execute it through the backtick operator. But this does not work on my windows2000 machine. Is there a better way to do this ? The CLASSPATH variable is required to be set by my perl script since it executes java code using backtick operators and requires the CLASSPATH to be set. Thanks!

Replies are listed 'Best First'.
Re: setting CLASSPATH thru perl
by diotalevi (Canon) on Aug 03, 2004 at 20:55 UTC
    Set $ENV{ 'CLASSPATH' }. See perlvar for the scoop on %ENV.
Re: setting CLASSPATH thru perl
by Plankton (Vicar) on Aug 03, 2004 at 21:11 UTC
    Why can't you just do ...
    ... `java -classpath /mypath/`; ...

    Plankton: 1% Evil, 99% Hot Gas.
Re: setting CLASSPATH thru perl
by revdiablo (Prior) on Aug 03, 2004 at 22:43 UTC

    You might consider using Inline::Java, rather than calling java with backticks. It may or may not work for you, but I think it's worth a look.