de.frame4j
Class Exec

java.lang.Object
  extended by de.frame4j.util.App
      extended by de.frame4j.Exec
All Implemented Interfaces:
AttrSettable, TextHelper.MessageComponents, UIInfo, ActionListener, EventListener, DynamicMBean

@MinDoc(copyright="Copyright 1998 - 2003, 2009  A. Weinert",
        author="Albrecht Weinert",
        version="V.1",
        lastModified="23.01.2010",
        lastModifiedBy="A. Weinert",
        usage="start as Java application (-? for help)",
        purpose="runs a java application, ant, another application or a script")
public class Exec
extends App

Run an application.

The name taken as the first non option parameter, thisJava application starts

Starting a Java application

Hereby the Java applications, i.e. their classes, searched for and started as described in AppHelper.executableObject().
Example:
  java Exec ant -help

All Java programmes and especially the inheritors of App are fully responsible for handling , formatting and perhaps branching their output and may be input. They run under the JVM of this application and as App's inheritors under the same framework (see AppBase). There will be no runtime limit.

Starting another application

If no Java application is found matching the first non option parameter, it is assumed that another programme of the underlying operating system residing in the actual directory is named. If possible it is run by Runtime.exec()) forwarding all remaining start parameters.

In the case of failure and if under Windows the programme "cmd.exe /C " will be tried to run as "Windows executable" forwarding the programme name and all remaining parameters.
Example:
      java Exec dir /s
would under Windows lastly succeed as     java Exec cmd.exe /C dir /s
which, of course cold have also been used in the first place.
Another example would be
      java Exec fc uhu.txt otto.txt

Normal and error output of the programme will be buffered and listed separately after the end. Additionally the return code will be logged. This is one comfortable way to research the in this respect often totally undocumented behaviour of Microsoft programmes.

The (non Java) programme started will get a maximum of 8 seconds runtime after the last output to out or err. This limit will be raised to 21 seconds after 12 seconds (with output). After this timeout a programme not yet ending itself will be sent lines with some usual quit and exit commands to its in. Afterwards it will be forcefully terminated.


Copyright 1998 - 2003, Albrecht Weinert

See Also:
App, AppHelper, AppHelper.OSexec, Input

Field Summary
 String command
          Application to be started; Java class, Ant, OS programme or script.
 
Fields inherited from class de.frame4j.util.App
ano, appBase, appIO, appStartTime, args, bgColor, err, fullClassName, help, icon, INIT_ERROR, jmxRemoteNote, JOB_DONE_OK, log, LOG_OUT_ERROR, MAIN_THREAD_EXC, mainThread, myClass, myFrame, name, NO_PARS_ERROR, objectName, out, outMode, packName, prop, retCode, runFlag, shortClassName, title, verbose, verbosity
 
Fields inherited from interface de.frame4j.net.AttrSettable
ILLEGAL_TYPE, ILLEGAL_VALUE, NO_ATTRIBUTE, NO_KNOWN_ATTRIBUTE, NO_VALUE, OK
 
Constructor Summary
Exec()
           
 
Method Summary
 int doIt()
          Working method of Exec.
static void main(String[] argv)
          Start method of Exec.
 
Methods inherited from class de.frame4j.util.App
actionPerformed, allowNoPropertiesFile, clientOrder, condHelpLog, connect, errMeld, errMeld, errorExit, errorExit, errorExit, errorText, formMessage, formMessage, getAbout, getAboutText, getActTime, getAppLogger, getAppStartTime, getArgs, getAttribute, getAttributes, getAuthor, getCopyright, getDbLogger, getExecTimeMs, getExecTimeString, getHelp, getHelpText, getIcon, getLanguage, getLogHandler, getMBeanInfo, getMessageComponent, getMessageComponentsLength, getMyFrame, getName, getNameWithVersDate, getOutMode, getProp, getPurpose, getStartTime, getStateString, getTitle, getUsage, getVerbosity, getVerbosityString, getVersDate, getXMLinput, go, go, go, haveIcon, invoke, isDebug, isHelp, isHelpLog, isNormal, isRunFlag, isSilent, isTest, isVerbose, logVerbose, logVerbose, makeDbLogger, makeMenuBar, makeMenuBar, makeStatusTextEnd, makeStatusTextStart, messageFormat, normalExit, parsePartial, performeAction, postDeregister, postRegister, preRegister, queueAction, registerAsMBean, setAboutText, setAttribute, setAttribute, setAttribute, setAttributes, setAuthor, setBgColor, setCodePages, setCopyright, setHelp, setJmxRemoteNote, setLogOut2, setName, setOutMode, setOutMode, setPurpose, setTitle, setUsage, setVerbose, setVerbose, setVerbosity, setVerbosity, setVerbosityString, setVersDate, stop, threeLineEndMsg, toString, twoLineEndMsg, twoLineStartMsg, valueLang, valueLang, wakeMainThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

command

public String command
Application to be started; Java class, Ant, OS programme or script.

Constructor Detail

Exec

public Exec()
Method Detail

main

public static void main(String[] argv)
Start method of Exec.

This programme ands with exit code 0, if it has run the ordered other application. This is success form Exec's point of view and says nothing about the other programmes success. Its exit code is logged.
An exit code > 0 means abort of the other's start due to problems

Parameters:
argv - command line parameter
Execution : Exec [options for Exec]   application [parameter]

doIt

public int doIt()
Working method of Exec.

Specified by:
doIt in class App
Returns:
> 0: error
See Also:
Prop, App.go(String[], boolean), App.go(String[], String, boolean, CharSequence), App.mainThread