0

I am trying to run a Perl program in Java.

I'm using:

process = Runtime.getRuntime().exec("getComps.pl");

but it is giving:

Exception: java.io.IOException: Cannot run program "getComps.pl": CreateProcess error=193, %1 is not a valid Win32 application

I have also tried:

process = Runtime.getRuntime().exec("cmd /c start getComps.pl");
process = Runtime.getRuntime().exec("cmd /c call getComps.pl");

But this is not giving any output.

It is giving the empty file after executing the program and taking lots of time to execute.

Is there an efficient way to call a Perl program from Java?

2 Answers 2

2

I would imagine the problem you're having is that a perl script isn't executable on it's own, you need to invoke Perl itself. Using your current approach you can probably just do the following:

process = Runtime.getRuntime().exec("perl getComps.pl")

But there are other options, take a look at the answers to this question.

Sign up to request clarification or add additional context in comments.

1 Comment

This will only look in the current directory for getComps.pl. To look on the PATH: "perl -S getComps.pl"
0

Have any one tried Perl2EXE? With this you can convert your perl to EXE and then call:

Process process = Runtime.getRuntime().exec("getComps <ARGS>")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.