Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling java from PERL

Status
Not open for further replies.

SirCharles

Programmer
Jun 10, 2002
212
US
I'd like to invoke a java program from PERL. When I try to do this, I get following error:
Exception in thread "main" java.lang.NoClassDefFoundError

If I go to the dir that contains the source code and classes, it works fine. So, how to invoke the java program from a different directory?
 
It depends on how your CLASSPATH environment variable is set. To run the java from any directory, add the full path to your java directory to your CLASSPATH. If you're on *nix, in ksh you can just do

export CLASSPATH=$CLASSPATH:/full/path/to/javaprogram

Greg.
 
I actually tried this already. Found same type of error occured. Following worked from PERL, but there ought to be something like what you're describing that's cleaner.
$runme = <<EORT;
cd /path/to/java/program
java javaProgram
EORT

`$runme`;


I've got another question on same subject. Not sure if I should post to this topic but here goes:
In order to access Oracle from java, do you have to use OC4J? Is there a sample Hello World program for accessing Oracle from java somewhere?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top