wood burning stoves
The moose likes Perl and the fly likes Problem calling perl from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Languages » Perl
Bookmark "Problem calling perl from java" Watch "Problem calling perl from java" New topic

Problem calling perl from java

Sneha Durvasula

Joined: Sep 26, 2013
Posts: 10
I need to call a perl script at a central location using java with arguements..I have used the following code and it does nothing..Can someone tell me whats missing

final List<String> commands = new ArrayList<String>();

ProcessBuilder pb = new ProcessBuilder(commands);
Process p1 = pb.start();
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11957

"Does nothing" isn't terribly specific. Does it compile? Does it throw an exception? Does it run but not do what you expect? If so, what DO you expect, and what - EXACTLY - did it print?

Do you know the perl script works? Can you call a simpler perl script and see if that works - something that would have a result you can see, like touching a file?

I have never called perl from java (or java from perl). I do know there are some caveats with using the process builder, but i've never really paid much attention. I'm sure if you search the various forums here you can find someone who has linked to it.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Brian Bykenhaal
Ranch Hand

Joined: Dec 17, 2013
Posts: 57
You need to create a caller org.perl.inline.java.InlinePerlCaller

I read that you need to use java inline also I have found some using XML-RPC and ProcessBuilder.

Rakudo lets you run Jvm and Perl 5 together. Rakudo Perl is a client compiler for the Parrot virtual machine and the Java Virtual Machine that implements the Perl 6 specification.

Java inline http://search.cpan.org/~patl/Inline-Java-0.52/Java.pod
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem calling perl from java
It's not a secret anymore!