• Post Reply Bookmark Topic Watch Topic
  • New Topic

calling perl from Java  RSS feed

 
udhaya kanagaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All,
Is it possible to call Perl from java.
If possible please let me know.
For calling perl from java ,what are the requirement
whether we have to include any jar files or something releated to perl

Thanks in advance

Regards,
Udhaya
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Java's exec() capabilities to start a Perl process just like you can run other applications. You must handle the resulting standard in, out and error streams as discussed many times in this and other forums.
You will have to have a Perl interpreter installed on your system, but nothing extra on the Java side.
Bill
 
Casper Maxwell
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also search for similar scripting languages to Perl available for Java. For example, the article below says Sleep and Perl is similar:

http://today.java.net/pub/a/today/2005/07/14/sleep.html
 
udhaya kanagaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
Thanks for your replies.
I shall try out that.

Regards,
Udhaya
 
udhaya kanagaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All,
I executed the following piece of code

try{

Process p1 = Runtime.getRuntime().exec("cmd.exe /c perl.exe -S
samplePerl.pl");

} catch(Throwable event){
System.err.println("Exception occured"+e);
}

It is not giving the output.can anyone tell the error in this or what I have to do further.
Thanks in advance

Regards,
Udhaya
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you expect the output to go?
See the Javadocs for java.lang.Process - paying especial attention to the discussion of the input, output and error streams.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!