Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "invoking perl script from java class" Watch "invoking perl script from java class" New topic
Author

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.



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

Joined: Aug 16, 2005
Posts: 14274
    
  21

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 8 API documentation
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invoking perl script from java class