wood burning stoves 2.0*
The moose likes Java in General and the fly likes invoking perl script from java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "invoking perl script from java class" Watch "invoking perl script from java class" New topic

invoking perl script from java class

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
Hi All,

I have a perl script. I have to invoke that script from java class . Can anyone tell me how to do this with help of any link or code snippet?i did google this and got somthing like
rt.exec("perl C:\\runPerl.pl");
but this is not working.

[ March 08, 2007: Message edited by: swapnil paranjape ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

Did you literally try to add this line to your code:

rt.exec("perl C:\\runPerl.pl");

then you discovered that it didn't compile and concluded that it didn't work? Or do you mean something else by "it didn't work"? If so, can you please tell use the error message you get?

You can use Runtime.exec(...) to execute system commands, for example to run the Perl interpreter (that's what the above line of code is trying to do). Ofcourse you need to have the 'perl' executable in the PATH, otherwise the system won't be able to execute it.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
Hi Jesper,

Thanks, a lot for quick reply. path variable was not set properly.

Its working now.

Warm Reagrds
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: invoking perl script from java class
Similar Threads
how to invoke perl script on unix server from local machine
Communication between Java and Perl
How to call execute a Java Program from a PERL script.
Is there a data structure in Java equivalent to the hash in Perl?
Do I have to use JNI to invoke Korn shell or perl script from java ?