Package org.apache.commons.exec.launcher
Class CommandLauncherImpl
- java.lang.Object
-
- org.apache.commons.exec.launcher.CommandLauncherImpl
-
- All Implemented Interfaces:
CommandLauncher
- Direct Known Subclasses:
CommandLauncherProxy
,Java13CommandLauncher
public abstract class CommandLauncherImpl extends java.lang.Object implements CommandLauncher
A command launcher for a particular JVM/OS platform. This class is a general purpose command launcher which can only launch commands in the current working directory.- Version:
- $Id: CommandLauncherImpl.java 1557338 2014-01-11 10:34:22Z sebb $
-
-
Constructor Summary
Constructors Constructor Description CommandLauncherImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Process
exec(CommandLine cmd, java.util.Map<java.lang.String,java.lang.String> env)
Launches the given command in a new process.abstract java.lang.Process
exec(CommandLine cmd, java.util.Map<java.lang.String,java.lang.String> env, java.io.File workingDir)
Launches the given command in a new process, in the given working directory.boolean
isFailure(int exitValue)
Checks whetherexitValue
signals a failure on the current system (OS specific).
-
-
-
Constructor Detail
-
CommandLauncherImpl
public CommandLauncherImpl()
-
-
Method Detail
-
exec
public java.lang.Process exec(CommandLine cmd, java.util.Map<java.lang.String,java.lang.String> env) throws java.io.IOException
Description copied from interface:CommandLauncher
Launches the given command in a new process.- Specified by:
exec
in interfaceCommandLauncher
- Parameters:
cmd
- The command to executeenv
- The environment for the new process. If null, the environment of the current process is used.- Returns:
- the newly created process
- Throws:
java.io.IOException
- if attempting to run a command in a specific directory
-
exec
public abstract java.lang.Process exec(CommandLine cmd, java.util.Map<java.lang.String,java.lang.String> env, java.io.File workingDir) throws java.io.IOException
Description copied from interface:CommandLauncher
Launches the given command in a new process, in the given working directory.- Specified by:
exec
in interfaceCommandLauncher
- Parameters:
cmd
- The command to executeenv
- The environment for the new process. If null, the environment of the current process is used.workingDir
- The directory to start the command in. If null, the current directory is used- Returns:
- the newly created process
- Throws:
java.io.IOException
- if trying to change directory
-
isFailure
public boolean isFailure(int exitValue)
Description copied from interface:CommandLauncher
Checks whetherexitValue
signals a failure on the current system (OS specific).Note that this method relies on the conventions of the OS, it will return false results if the application you are running doesn't follow these conventions. One notable exception is the Java VM provided by HP for OpenVMS - it will return 0 if successful (like on any other platform), but this signals a failure on OpenVMS. So if you execute a new Java VM on OpenVMS, you cannot trust this method.
- Specified by:
isFailure
in interfaceCommandLauncher
- Parameters:
exitValue
- the exit value (return code) to be checked- Returns:
true
ifexitValue
signals a failure- See Also:
CommandLauncher.isFailure(int)
-
-