Re: How to call .jar files from perl program
by dHarry (Abbot) on Dec 17, 2008 at 14:31 UTC
|
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//
| [reply] [d/l] [select] |
|
|
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?
| [reply] |
|
|
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?
| [reply] |
|
|
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.
| [reply] |
|
|
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.
| [reply] |
|
|
| [reply] |
Re: How to call .jar files from perl program
by tmaly (Monk) on Dec 17, 2008 at 14:43 UTC
|
You could also use Inline::Java to call jar files. You essentially put all your java code in a string plus the import line for the jar. I usually declare a simple java class that calls the jar code. The Inline::Java will generate the translation from the Java class to the perl domain then you simply instantiate the object in perl and make the call to the method that in turn calls the jar code. | [reply] |
|
|
Can you please give me an example how do you call a jar from perl so that both the application run simultaniously?
| [reply] |
Re: How to call .jar files from perl program
by Anonymous Monk on Dec 17, 2008 at 07:29 UTC
|
Use system or exec, just like you would for any executable. | [reply] |
Re: How to call .jar files from perl program
by anupamde (Initiate) on Jun 19, 2009 at 11:06 UTC
|
While we call a Jar file from a perl application 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.
Can anyone one tell me how we can access both the application simultaniously?
| [reply] |
|
|
| [reply] |
|
|
| [reply] |
|
|
Re: How to call .jar files from perl program
by Anonymous Monk on Aug 30, 2013 at 09:00 UTC
|
getting error:-Failed to load Main-Class manifest attribute from <jar file> | [reply] |
|
|
| [reply] |