CleanCode Perl Libraries |
Home | Perl | Java | PowerShell | C# | SQL | Index | Tools | Download | What's New |
Multi-Lingual Library | Maintainability | ||||||||||||
Perl | Java | JavaScript | Certified Class |
Testable Class |
Standalone Mode |
Diagnostic Enabled |
Proc::ExecJava - Executes a Java program.
use Proc::ExecJava;
$javaProg=Proc::ExecJava->new(
$JAVA_BIN_PATH,$JAVA_CLASS_PATH,"com.cleancode.net.URLReader");
$javaProg->setSystemProperties("verbose");
$javaStatus = $javaProg->run($url, $cookie);
return ($javaStatus? "java error" : $javaProg->output());
Perl5.005
This module allows you to run a Java program specifying (1) the path to your Java binary; (2) the path to your Java class library; (3) the class to execute; (4) any system properties; and (5) parameters to pass on the command line to the class.
You specify the first three in the object constructor. System properties, if needed, may be specified via the setSystemProperties
method, Each of these will appear between the java interpreter and the class, as in
java -Dprop1 -Dprop2=foobar -Dprop3 class_to_run
Note that you should not include the -D
itself.
You may then run the Java program one or multiple times via the run
method, varying the properties, if desired, and the command-line arguments. The command-line arguments are passed directly to the run
method. If the run
method returns a status of 0, then you can obtain the output of the run via the output
method.
Current version of this class.
PACKAGE->new(binPath, classPath, className)
Creates a Java
object with which to execute a Java program.
binPath
- optional; string; path to the Java executable. If not specified, your default search path will be used.
classPath
- optional; string; java class path. This contains a list of directories to search for required classes, separated by semicolons. If not specified, your default CLASSPATH
environment setting will be used.
className
- string; java class name to execute.
a newly created object
OBJ->setSystemProperties(arg,...)
Specifies a list of system properties to pass to the Java interpreter. Any previous system properties will be deleted. Hence, to ensure no leftover properties from previous invocations during the lifetime of the enclosing Perl program invoke setSystemProperties
with no arguments.
arg
- optional; string; system property of the form name or name=value.
OBJ->run(arg,...)
Executes the Java program defined by the constructor with the list of system properties from setSystemProperties
, and the list of args specified here.
arg
- optional; string; command-line argument to pass to the Java program.
Java program status (0 indicates normal termination).
OBJ->output()
Returns the output of the Java program.
Output of the Java program. The output is returned as a list or as a string, depending on context of the caller.
None
Michael Sorens
$Revision: 8 $ $Date: 2006-12-19 21:13:43 -0800 (Tue, 19 Dec 2006) $
CleanCode 0.9
Hey! The above document had some coding errors, which are explained below:
=back doesn't take any parameters, but you said =back -- end of CLASS VARIABLES section
=back doesn't take any parameters, but you said =back -- end of CONSTRUCTOR section
=back doesn't take any parameters, but you said =back -- end of METHOD section
Home | Perl | Java | PowerShell | C# | SQL | Index | Tools | Download | What's New |
CleanCode Perl Libraries | Copyright © 2001-2013 Michael Sorens - Revised 2013.06.30 |