Home
TeamSite
Calling Java from Perl
vp98aa
Hello,
I have a DCT that includes an inline callout calling an ipl (perl) file. In that perl file I call a Java class that will return me a unique number that I need to plug into the DCT. Below is the code for the DCT and the ipl file.
If I run the ipl file using iwperl from the command line, then it runs great. It returns the value that I am looking for. However if I pull up (run) the DCT then it does NOT return proper value and it gives me Java Exception Error.
I am guessing that calling Java from Perl would run in its own environment and would NOT have access to the DOS/Windows environment variables. I tried setting these variables using: $ENV{'PATH'} = "blah blah blah"; something like that. But that didnt work either.
Any ideas?
Thanks,
Here is the DCT:
----------------------------------------------------------------------
<item name="refnumber" pathid="refnumber">
<label>Ref#</label>
<inline command="d:/iw-home/iw-perl/bin/iwperl d:/iw-home/custom/bin/getNumber.ipl"/>
</item>
----------------------------------------------------------------------
Here is the getNumber.ipl:
----------------------------------------------------------------------
#!d:/iw-home/iw-perl/bin/iwperl.exe
$iwhome = "d:/iw-home";
my $java_bin = "$iwhome/tools/java1.3/bin/java";
$ENV{'JAVA_HOME'} = $java_bin;
my $cp = "\"D:\\iw-home\\custom\\bin\\RI_DB\\RI.jar;D:\\iw-home\\custom\\bin\\RI_DB\\StarSQL_JDBC.jar;D:\\iw-home\\custom\\bin\\RI_DB\\starlicense.cfg;\"";
print <<EOF;
<substitution>
<text required="f" size="100" maxlength="100">
<default>
EOF
my $out = system("$java_bin -cp $cp RiReferenceNumber");
print <<EOF1;
</default>
</text>
</substitution>
EOF1
----------------------------------------------------------------------
Find more posts tagged with
Comments
mogoo
We had a similar problem calling java from a workflow. What we finally figured out is, from the teamsite environment, the java wasn't running from the server's root level. So we built an external ipl that chdir's before it ran the java, like so...
#get current directory
my $cwd = getcwd;
print "cwd: $cwd\n";
#chdir to root directory
chdir "/";
#execute Xylan command
system("$cmd");
print "cmd: $cmd\n";
#chdir back to original directory
chdir "$cwd";
...hope that helps.
maureen