Starting and stopping applications via a Java-application on Windows/Unix

Hello,
I want to start java and other applications via a java application.
This java application should start several different applications on windows and
on unix systems and take care of their current state (e.g. running/not running).
For all applications to be started there are .sh-scripts for unix and .bat-scripts
for windows. In the scripts there could be a java call, e.g. "java someApplication",
or some executables could be called. These scripts set the applications' environment etc.
and start the application finally.
My java application calls these scripts via the ProcessBuilder API, which is working fine.
But there is the following problem: on windows, when executing a script that starts
some other application, the ProcessBuilder gives me process-handle to the started
process. If calling destroy() on this handle, only the cmd.exe gets killed which
started the application. The application itself is running on. This is undesired behaviour
since I want to be able to control the started applications, at least start and stop it which
is impossible that way.
On unix, it is working when using
"exec java someApplication"
instead of just
"java someApplication"
in the .sh-scripts. The exec command substitutes the shell process with the underlying
process started in the script, so everything is working as expected on unix.
But how could I get this working on windows systems? Is there any equivalent to the exec
command on unix? Any suggestions appreciated.
If something's unclear in my description, please let me know.

Yes - after looking at this option - I think that's the direction I am going to go. It probably makes sense to give my JMS topics and my BPEL server their own OC4J instances anyway - for a number of reasons.
Lon

Similar Messages

  • Starting and Stopping a Timer in Java Card + GSM

    Hi,
    I seem to not be able to start a timer that my applet has
    allocated using the PRO_CMD_TIMER_MANAGEMENT
    pro active command. I want to for example set the timer
    interval to 5 seconds and I understand from the gsm
    specs that the TLV value should then be {(byte) 0x00,
    (byte) 0x00, (byte) 0x05} as the hour is zero, the minute is
    zero and the seconds = 5 .
    The command qualifier I set to 0x00 to start the timer and
    I set it to 0x02 to stop the timer. The start and stop I
    control from two menu items. From the GSM spec the first 2 bits
    control the timer and the remaining 6 are RFU (reserved for future use),
    now I assume I can then set the RFU bits to 0.
    I then have a EVENT_TIMER_EXPIRED in my processToolkit which then plays a tone.
    The tone proactive command works but I dont seem to be able to start the time or
    stop it ?
    HELP ?
    is there any suggestions or any error in my reasoning here ?

    I tried your solution but it seems to have no effect (?)
    This is the log entry of the comms during sneding of the timer start
    command:
    (Notice that where you have the Timer Identifier tag = A4, here it is
    24 and where you have Timer Value Tag = A5, here it is 25 - these tags and the APDU's are generated with the GSM java card libs in the development kit I'm using.....) It seems to go through but the TIMER_EVENT_EXPIRED never happens....Help ? Have a look at the source code I included (maybe I'm doing something wrong)....
    **THE APDU's
    //346:
    A0 12 00 00 13
    //Fetch
    //     RAPDU = D0 11 81 03 01 27 00 82 02 81 82 24 01 01 25 03 00 00 10
    //     SW = 9000
    //347:
    A0 14 00 00 0C 81 03 01 27 00 02 02 82 81 03 01 31
    //>>Terminal response
    //     SW = 9142
    **SOURCE CODE
    //IN A METHOD CALLED FROM A MENU ITEM SELECTED
    byte[] valCurrentCallUnit = {
    (byte)0x00, (byte)0x00, (byte)0x10
    }; //i.e. 1 second
    timerHandle = reg.allocateTimer();
    proHdlr.init(PRO_CMD_TIMER_MANAGEMENT,(byte)0x00,DEV_ID_ME);
    proHdlr.appendTLV((byte) TAG_TIMER_IDENTIFIER,timerHandle);
    proHdlr.appendTLV((byte) TAG_TIMER_VALUE,valCurrentCallUnit,
    (short) 0, (short) 3);
    result = proHdlr.send();
    //the following is not suppose to be required according to GSM 11.14
    reg.setEvent(EVENT_TIMER_EXPIRATION);
    //IN THE processToolkit method, I have:
    public void processToolkit(byte event) {
         EnvelopeHandler envHdlr = EnvelopeHandler.getTheHandler();
         ProactiveHandler proHdlr = ProactiveHandler.getTheHandler();
         ProactiveResponseHandler rspHdlr;
    switch(event) {
    case EVENT_TIMER_EXPIRATION:
    doSomething();
    proHdlr.init(PRO_CMD_TIMER_MANAGEMENT,
    (byte)0x00,DEV_ID_ME);
    proHdlr.appendTLV((byte) TAG_TIMER_IDENTIFIER,timerHandle);
    proHdlr.appendTLV((byte) TAG_TIMER_VALUE,valCurrentCallUnit,
    (short) 0, (short) 3);
    result = proHdlr.send();
    break;
    } /** switch event */
    }/** processToolkit */
    Any help would be appreciated....

  • Starting and Stopping BPEL via opmnctl

    Hi All,
    This should be easy - but I'm having some problems...
    What I want to do is to script a nightly purge of my BPEL DB tables.
    I have a working script that stops the whole App Server (opmnctl stopall), runs my SQL script and starts the app server again (opmnctl startall). The problem is that we have another application that is continually trying to write data to the OC4J JMS topics. By taking the whole app server down, the other app starts throwing exceptions because it can't write to the JMS topics.
    I would think there would be a way I can take down only the BPEL process while I purge the DB - and still allow the JMS topics take in new messages. I tried the following...
    $OAS_HOME/opmn/bin/opmnctl stopproc application=orabpel
    <sql script >
    $OAS_HOME/opmn/bin/opmnctl startproc application=orabpel
    But after running this, my BPEL Console showed no processes loaded. I had to restart the whole app server to get them back.
    I also tried ...
    $OAS_HOME/opmn/bin/opmnctl stopproc ias-component=orabpel
    <sql script >
    $OAS_HOME/opmn/bin/opmnctl startproc ias-component=orabpel
    But this kicked back errors saying " No processes or applications match the specified configuration."
    I suppose I could create a new OC4J instance for my JMS Topics. Then I should be able to start/stop either OC4J without affecting the other one. Is this the best solution?
    Any help is greatly appreciated!
    Lon
    Oracle Consulting

    Yes - after looking at this option - I think that's the direction I am going to go. It probably makes sense to give my JMS topics and my BPEL server their own OC4J instances anyway - for a number of reasons.
    Lon

  • How to start and Stop Running services with Java Programme

    I have some Service Runinig on My Windows machine like Tomcat Server,i want to update some file in Tomcat server through java program ,it works only when my tomcat stops ,I want to write peice of Code so that i can stop service with my prog and start after updating my files

    heres something that may help yeah
    http://wrapper.tanukisoftware.org/doc/english/introduction.html

  • Script to auto start and stop an application

    Ok, I'm looking for an easy solution, maybe someone can point me in the right direction:
    I have a security camera program that runs on a Mac Mini that I would like to start and stop at a specific time of day. Is there an easy way to create an Applescript to do that?
    Thanks much in advance.

    Two scripts and iCal can do this for you. However, it assumes that your workstation is always logged into the Finder and that your app can be scripted beyond start and stop.
    --Script 1, launch application
    tell application "name of security app"
    activate
    -- do more stuff here like start capture
    end tell
    --Script 2, quit the application
    tell application "name of security app"
    quit
    end tell
    Save them both as scripts and then use iCal to make two repeating events. One to start the app and the other to stop it. Attach your scripts as event actions. Then sit back and let the iCal schedular the rest.

  • Pump Start and Stop?

    While making the I/O list, I have identified theDigital Ouput,  Port0/line1 as start for the pump and Digital Output, Port0/line1 for stop i.e is two port, lines, of the pump...but while making the software, VI, I am using the verticle toggle switch to consider the start of pump as up and stop as down of the toggle switch which works at one DO port line.
    How can I give two signal start and stop to the pump?
    Should I use two buttons? Which ones?
    I am confused. Please let me know.

    What do the two DO lines do?  Ultimately there will be one device (contactor, relay, thyristor, ...) which has two states (like a single boolean) to turn the pump on and off.  How do the two digital lines connect to that control device?  Are they inputs to some kind of electronic pump controller or are they simulating the standard industrial Start and Stop buttons via relays? Something else?
    You can use the single switch on the front panel and the boolean Not function to create the two lines for your DO.
    Lynn

  • Starting and stop Oracle 9i database

    Hello;
    Can anybody tell me how to start and stop an Oracle 9i database manually with Window NT 4 ?
    thanks a lot !

    - start/settings/configuration pannel/services
    - select the oracle service
    - press start or stop button
    Hello;
    Can anybody tell me how to start and stop an Oracle 9i database manually with Window NT 4 ?
    thanks a lot !

  • How to start and stop Oracle Application Server from ANT

    How to start and stop Oracle Application Server and Web application from ANT
    Thanks in Advance.
    Mani

    Hi,
    You can use: startManagedWebLogic.sh, it is in your domain directory and you have to execute it in this way
    ./startManagedWebLogic.sh managedServerName http://adminServerHost:adminServerPort
    For instance, in my case I use:
    unixserv01:/webportal/domains/appServerWeb/bin>startManagedWebLogic.sh managedServ01 http://pelma3w3per01.mesaperu.next:7001
    You have to run it on the machine where the managed server was installed.
    Best regards,
    Raúl

  • HT1355 can an application start and stop airplane mode?

    can a native application start and stop airplane mode on the iPhone and iPad?

    No.  It must be done manually by the phone user.

  • Start and stop the Communication channel from Java Mapping

    How to start and stop the Communication channel from Java Mapping in XI 3.0
    Scenario  PI - > MQ -> Third Party web application 
    Web application is down and then Communication channels are stop manually .  
    We need to automate this process,
    MQ Solution - Trigger will be set in MQ which will be called when web application is stopped
    Trigger will send u201CSTOP u201C message to PI
    How to configure PI scenario to stop different com channels when this message received ?

    check this link: http://help.sap.com/saphelp_nw04/helpdata/EN/45/0c86aab4d14dece10000000a11466f/frameset.htm
    make sure that MQ send http request to PI. i dont think a configuration scenario is required in PI. Only roles should be enabled with proper user provided to MQ team.
    However, for security reasons, you can configure a scenario if you dont want to expose PI infrastructure directly to 3rd parties.

  • Start and Stop a Windows Service From Java

    Is there any way to start and stop a Windows service from Java? The only post I found on it (http://forum.java.sun.com/thread.jspa?threadID=647509) had a link to one of the many aps that allow Java programs to be services, which is not what I am interested in doing.
    I am attempting to get data from performance counters from the Windows Performance Monitor into a Java ap without using JNI. I can get the data from C++ or a .net language pretty easily and was going to create a service that would listen for socket requests and feed back the data. However, I'd like to start and stop that service when my java code starts and stops. Is this possible? Would it make more sense to just use a .exe and Runtime.exec()?

    If it's only to start or stop a service then you could use the net command without any need for JNI.import java.io.*;
    public class MsWinSvc {
        static final String CMD_START = "cmd /c net start \"";
        static final String CMD_STOP = "cmd /c net stop \"";
        public static int startService(String serviceName) throws Exception {
            return execCmd(CMD_START + serviceName + "\"");
        public static int stopService(String serviceName) throws Exception {
            return execCmd(CMD_STOP + serviceName + "\"");
        static int execCmd(String cmdLine) throws Exception {
            Process process = Runtime.getRuntime().exec(cmdLine);
            StreamPumper outPumper = new StreamPumper(process.getInputStream(), System.out);
            StreamPumper errPumper = new StreamPumper(process.getErrorStream(), System.err);
            outPumper.start();
            errPumper.start();
            process.waitFor();
            outPumper.join();
            errPumper.join();
            return process.exitValue();
        static class StreamPumper extends Thread {       
            private InputStream is;
            private PrintStream os;
            public StreamPumper(InputStream is, PrintStream os) {
                this.is = is;
                this.os = os;
            public void run() {
                try {
                    BufferedReader br = new BufferedReader(new InputStreamReader(is));
                    String line;
                    while ((line = br.readLine()) != null)
                        os.println(line);
                catch (Exception e) {
                    e.printStackTrace();
    }Regards

  • Start and Stop bpel using APIs

    Dear All,
    we have a production on 10.1.3.4
    we have a requirement to start and stop a list of BPELs including their adapters without shutting down the SOA Server.
    I could see in Process table there are values for life_cycle and active.
    is that the best way to inactivate a service ?
    Is there any API which can be used for the same ?
    Thanks for your advise.
    Best Regards
    Arc

    Hi,
    You can do certain things via IBPELDomainHandle (see [http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/com/oracle/bpel/client/IBPELDomainHandle.html]) but BPEL and the adapters are really no more than j2ee applications that run in an oc4j container. If you want to stop bpel or adapters you can stop the applications from the enterprise manager website. I think there are also oc4j administration java api's but i have no experience with them. I would certainly not update dehydration store tables.
    Kind Regards,
    Andre

  • Batch file to start and stop

    Hi All,
    Can we create a batch file to start and stop the services. I need to start all the services like shared, essbase, eas, planning, webanlysis and financial reporting, and at also need to stop them using windows batch file.(Using windows 2003 server....service pack 1). Any help would be appreciated.
    Thanks

    Hi,
    The simplest script would be something like this. Save it as a .bat file, set all your services to manual and then set up a scheduled task to run this script when the computer starts.
    Gee
    ::          Startup Script for Hyperion Services          ::
    date/t >> startup.log
    time/t >> startup.log
    echo "Starting Hyperion Services" >> startup.log
    net start "Hyperion S9 OpenLDAP" >> startup.log
    net start "Hyperion S9 Shared Services" >> startup.log
    :: Insert pause of 5 seconds to ensure HSS has finished starting
    ping localhost -n 6 >nul
    net start "Hyperion S9 BI+ Analytic Services 9.3.1 - Essbase" >> startup.log
    net start "Hyperion S9 Administration Services ATS5" >> startup.log
    net start "HyperionRMIRegistry" >> startup.log
    net start "Hyperion S9 Planning" >> startup.log
    net start "Hyperion S9 Provider Services ATS5" >> startup.log
    net start "Hyperion S9 Apache 2.0" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Core Services 1" >> startup.log
    :: Insert pause of 10 seconds to ensure Core has finished starting
    ping localhost -n 11 >nul
    net start "Hyperion S9 BI+ 9.3 Workspace" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Financial Reporting Java RMI Registry" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Financial Reporting Print Server" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Financial Reporting Report Server" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Financial Reporting Scheduler Server" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Financial Reporting Web application" >> startup.log
    net start "Hyperion S9 BI+ 9.3 Web Analysis" >> startup.log
    date/t >> startup.log
    time/t >> startup.log
    echo "Finished Starting Hyperion Services" >> startup.log
    echo "###################################################################" >> startup.log

  • Starting and stopping SAP J2EE Engine

    Hi guys,
             I have downloaded and installed trial version of SAP Web Application Server (SAP Web AS) Java 6.40 for Microsoft Windows XP.
       I wanted to launch SAP J2EE Engine and Software Deployment Manager (SDM) to run my web dynpro application. The Netweaver Developer studio getting started guide has a link for starting and stopping the SAP J2EE Engine but its not working for me. I get an error with the link.
    Is it possible for someone to let me know how to launch J2EE engine and SDM. Also what server settings I need to make in the menu path Window -> Preferences -> SAP J2EE Engine.
    Any help will be appreciated.
    Thanks,
    Mandar

    Hi Ivaylo and Thomas,
        Thanks for your help, It works fine. For some reason after starting my J2EE server, when I start my Netweaver developer studio, it gives the following error
       JVM Terminated Exit code=1
       c:\j2sdk1.4.2_05\bin\javaw.exe
       -Xmx512m
       -Xms128m
       -XX:PermSize=128m
       DallUserDir='C:\Documents and Setting\All users\Application Data'
       -cp C:\Program Files\SAP\JDT\eclipse\SAPStartup.jar com.sap.ide.eclipse.startup.Main
       -os win32
       -ws win32
       -arch x86
       -feature com.sap.java.ide
       -showsplash C:\Program Files\SAP\JDT\eclipse\SAPIde.exe -showsplash 600
      Any idea why I get this error and how to fix it. My Netweaver Developer studio did startup few times and I did write some code in it. But now when I try to start NDS, I get the above error.
    Any help will be appreciated.
    regards,
    Mandar

  • Does Golden Gate provide any Webservices to start and stop services?

    Hi all,
    We are trying to use GG in our application. But we need a way to start and stop services from java code.
    Is there any Webservice interface or API to start and stop Golden gate services like GG manager, extract and replicat processes??
    Thanks in advance for your help.
    Yamini.

    You can control this at a database level using EVENTACTIONS parameter.
    Create a table at source & target called "EVENT" with field EVENT_TYPE ( example names only - please call it what you like ) .
    at Replicat config actions based on the data passed into the EVENT_TYPE column
    MAP GG_ADM.EVENT TARGET GG_ADM.EVENT, &
    FILTER ( (@STREQ(@IF(@COLTEST(EVENT_TYPE,PRESENT),EVENT_TYPE,"No EVENT"),"STOP") = 1)), &
    EVENTACTIONS (IGNORE , LOG,STOP);
    You'll need a seperate replicat to handle the start
    MAP GG_ADM.EVENT TARGET GG_ADM.EVENT, &
    FILTER ( (@STREQ(@IF(@COLTEST(EVENT_TYPE,PRESENT),EVENT_TYPE,"No EVENT"),"START_APP_02") = 1)), &
    EVENTACTIONS ((SHELL (${GG_HOME}/diroby/start.ksh R1APP_02 )));
    Hope that helps

Maybe you are looking for

  • MacBook Pro unable to boot up [Stop Sign], after rEFIt Installation

    I was trying to install Windows on my MacBook Pro, Intel Based. Followed this tutorial, http://riactant.wordpress.com/2009/02/25/install-windows-on-boot-camp-using-exte rnal-usb-optical-drive/ Downloaded and installed rEFIt and rebooted my MacBook Tw

  • Broken Links inside FLash

    I notived that the links inside my flash header do not work on this page as well as other pages inside this directory. The links do work in the root directory. Does someone know how to fix this problem I am having? Here is the link: http://www.school

  • I've lost my game toolbars and i can't get them back, how do I get them back?

    I have two FF brousers and one of them was safe mode. I clicked on safe mode and a box popped up and had a couple links on it. I meant to click something else but instead i clicked 'disable toolbars' . I went on my normal FF and my toolbars I had, so

  • Different offsetting account displayed in FB03 and KSB1

    Hi, We have a problem, the number of offsetting account displayed for documents in FB03 is different than number displayed in KSB1 report. Notes 755291and 806041 are already implemented. regards, Rafal

  • Reg: field names in FI module

    Hi to all,     I need to generate report.. but i have to maintain input fields like company code , fiscal year & period. which fields i have to take to required input.  Table name & field names please let me know,,, I am waiting for your response....