in reply to How to call .jar files from perl program

To elaborate a little further: exec executes a system command and never returns, system does return. I'd prefer system, something like:

# @args = ("command", "arg1", "arg2"); my @args = ("java", "-jar", "Saxton.jar"); system(@args);

You can inspect the $? variable to check what/if anything went wrong. If you want to capture the output of the command you can use backticks or qx//

Replies are listed 'Best First'.
Re^2: How to call .jar files from perl program
by anupamde (Initiate) on Jul 14, 2009 at 07:54 UTC
    While we call a jar file from the perl using the following syntax my @args = ("java", "-jar", "Saxton.jar"); system(@args); It is opening the jar application along with a command prompt window. Is there any way to disable the command prompt window?
Re^2: How to call .jar files from perl program
by Anonymous Monk on Jun 22, 2009 at 11:22 UTC
    While we call a Jar file from a perl application using System() the Jar file is invoked and run normally. At that time we are not able to access the calling Perl Application. When we close the called java application then we are able to access the Perl application. On the other hand if we use the EXEC() to invoke the jar file then the jar invoke and the perl application will close. Can you please suggest how we can call a jar file from the perl application and access both the application(perl and jar)simultaniously?

      You didn't mention this in your original post. Maybe you should elaborate a little bit more what exactly it is you are trying to achieve. There are several modules around to use Java from Perl (or the other way around). For example Java a module that allows you to talk to a JVM (local machine or remote), and with Java::Import you can use Java classes in Perl. See below in other responses for more suggestions. Obviously you want to parse XML document and apply XSLT transformations, there are ways of doing this in a more Perlish way. Are you stuck with Saxon? And also where does Perl exactly come in? You could also consider a pure Java/Saxon solution. Please elaborate the problem a little bit more to clarify.

Re^2: How to call .jar files from perl program
by Anonymous Monk on Jul 13, 2009 at 15:12 UTC
    While we call a jar file from the perl using the following syntax my @args = ("java", "-jar", "Saxton.jar"); system(@args); then it invoke the jar window and also invoke a command prompt window as well. Can any one tell how I can disable the command prompt that is invoked while I call my jar file? I just want to run the jar file, not the command prompt.