Keep external process alive after System.exit(0)

I wish to start Outlook from my Java program and have my own program exit normally but keep alive the Outlook process. Besides, I am not interested in input/output/error streams.
public class OutlookStarter {
     public static void main(String[] args) throws Exception {
          new ProcessBuilder("cmd", "/c",
                    "\"C:\\Program Files\\Microsoft Office\\Office14\\outlook.exe\"")
                    .start();
}When I run this when Outlook is not started, my program will not exit until I close Outlook.
I really do not want to close Outlook just to exit my program (my real program has a Swing GUI and users must be able to close it).
Also when I run this when Outlook is already started, somehow my program DOES exit without closing the new Outlook window.
EDIT: I can add System.exit(0) and behavior is the same. I can use Runtime.getRuntime().exec and behavior is the same.
Edited by: Strider80 on Jan 12, 2011 7:27 AM

Strider80 wrote:
I wish to start Outlook from my Java program and have my own program exit normally but keep alive the Outlook process. Besides, I am not interested in input/output/error streams.
public class OutlookStarter {
     public static void main(String[] args) throws Exception {
          new ProcessBuilder("cmd", "/c",
                    "\"C:\\Program Files\\Microsoft Office\\Office14\\outlook.exe\"")
                    .start();
Did you try using [url http://www.computerhope.com/starthlp.htm]start ^[url http://www.computerhope.com/starthlp.htm]Microsoft DOS and command prompt^ ?
          new ProcessBuilder("cmd", "/c",
                    "start \"C:\\Program Files\\Microsoft Office\\Office14\\outlook.exe\"")
                    .start();

Similar Messages

  • Spawning another java process after System.exit(0);

    Hi everyone
    I have an application that Im trying to test. Unfortunately one of these tests requires me to spawn another java process after a System.exit(0); has executed. Since this exits the VM its proving very difficult. Does anyone know of a way to restart the VM after the System.exit has run?
    Thanks

    Hi everyone
    I have an application that Im trying to test.
    Unfortunately one of these tests requires me to spawn
    another java process after a System.exit(0); has
    executed. Since this exits the VM its proving very
    difficult. Does anyone know of a way to restart the VM
    after the System.exit has run?Exactly what do you want to do?
    If the application is supposed to only have one exit point then add a security manager and disallow all the other exit points. Then you can use Runtime.exec() to start the second application just before the real exit point.
    However note that if there are other calls to System.exit in the application then it is very likely that this will cause some unexpected failures in terms of security exceptions.
    You could also use Runtime.addShutdownHook() which would run your second app. The hook would be called as the application exits.
    You might want to consider what happens if someone just kills the application (say with 'kill -9' or the windows task manager.) In either of those cases there is nothing that you can do in java to make that second application run.
    You might also want to consider why you are doing this in the first place. As suggested a script solution is probably a better solution.

  • Process in memory after System.exit(0)

    I still see the process in memory after I exit the app. Do you think it is a JWS side effect?
    Platform: W2K
    Cheers,
    Ivan

    Ivan,
    when you enable the 'java console' in Java Web Start->Preferences->Advanced->Show Java Console, you'll notice that you run into a java.security.accessControlException.
    To avoid that, sign your jar file(s) and add the following to your jnlp file :
    <security>
    <all-permissions>
    </security>
    and it will work as expected!
    Regards,
    Patrick

  • Why in COM, set smth true, stays true even after System.exit?

    I am using "Jacob" to do COM calls. When I alter the "ShowAll" property of Word.Application and I set it to true, it will then forever be true even if I exit the application AND quit the word application. If I set it to false, the same thing happens, it will always be so. The code to call/set this is:
    (NOTE: This uses classes I made to wrap the Dispatch calls)
    Word wordApp = new Word();
    Documents docs = wordApp.getDocuments();
    Document doc = docs.open("D:\\JavaProjects\\Test.doc");
    //GET VIEW
    View wordView = wordApp.getActiveWindow().getView();
    //PRINT THE VIEW PROPERTIES
    System.out.println("Show All: " + wordApp.getActiveWindow().getView().isShowAll());
    System.out.println("Show Paragraphs: " + wordApp.getActiveWindow().getView().isShowParagraphs());
    //SET THE VIEW PROPERTIES
    wordView.setShowAll(false);
    wordView.setShowParagraphs(true);
    //PRINT THEM AGAIN
    System.out.println("Show All: " + wordApp.getActiveWindow().getView().isShowAll());
    System.out.println("Show Paragraphs: " + wordApp.getActiveWindow().getView().isShowParagraphs());
    doc.close(Document.DO_NOT_SAVE);
    wordApp.quit(new Variant[] {});
    System.exit(0);The actual Dispatch calls are:
    //NO IDEA WHY THIS IS, BUT SHOWALL = TRUE IS -1, AND FALSE IS 0
    private final static int SHOW_ALL_TRUE = -1;
    private final static int SHOW_ALL_FALSE = 0;
    /** SETSHOWPARAGRAPHS **
    * Sets the property (boolean) ShowParagraphs.
    public void setShowParagraphs(boolean showParagraphs)
         Dispatch.put(this, "ShowParagraphs", new Boolean(showParagraphs));
    /** ISSHOWPARAGRAPHS **
    * Returns Boolean of whether or not this is set to show paragraphs.
    public boolean isShowParagraphs()
         return getBooleanValue(Dispatch.get(this, "ShowParagraphs"));
    private boolean getBooleanValue(Variant variantBoolean)
         //MAKE IT AN INTEGER AND GET ITS int VALUE
         int intVariant = new Integer(variantBoolean.toString()).intValue();
         //RETURN IF IS SHOW ALL
         return (intVariant == View.SHOW_ALL_TRUE);
    }I'm wondering if the problem is that I get back either -1 or 0 and if maybe that means something else?

    1: Properties persistence is not a DEFECT but a FEATURE . It was implemented in MS Word so users could change MS word WITHOUT HAVING TO DO IT EACH TIME THEY START IT UP.
    2: Don't you intialise all your variables in your code after you instanciated them ? I am sure you do so and therefore the persitence feature you described should not be annoying you at all. It is not necessary to intialise variables in the BASIC langage but that does not mean you should not do it.
    3: (-1) was chosen arbitrary by Microsoft as the TRUE value for Boolean datatype and 0 the value for FALSE when they designed Visual Basic. This is not a problem if you write code properly
    I recommend you test bool variable in any langages using the following test:
    (myBool <> 0)
    HAVE A THINK ABOUT IT
    Finally,
    you need to understand what you are working with before you complain about it.
    Argument for Argument sake is not good and if you think MS word is a bad program just don't use it. go and write your own word processor in JAVA.
    GOOD LUCK
    I WISH TO APOLOGISE FOR ANY POSSIBLE SPELLING OR GRAMMATICAL MISTAKES I COULD HAVE MADE IN THIS REPLY. ENGLISH NOT BEING MY FIRST LANGUAGE.

  • Read sharing violation after System.exit in oracle lite DLL

    I am using JRE 1.3 and successfully managed running some sql statements over jdbc.
    When the java class is finished (implicit exit) then no error appears.
    When I exit the code using System.exit(0) there is a windows dialog
    showing a read access error AFTER the java class finished.
    probably there is some cleanup the oracle DLL wants to do after the JVM exited?
    Please help mailto:[email protected]
    The sample code below can be used.
    * Title:
    * Description:
    * Copyright: Copyright (c) 2001
    * Company:
    * @author Ivan Motsch
    * @version 1.0
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    public class TestOracleLite{
    public TestOracleLite(){
         public void start(){
              Statement stm=null;
              Connection conn=null;
              try{
                   Properties p=new Properties();
                   p.setProperty("user","system");
                   p.setProperty("password","manager");
                   p.setProperty("DataDirectory","..\\..\\..\\TEMP\\ora4\\db");
                   p.setProperty("Database","ORS");
                   p.setProperty("IsolationLevel","Read Committed");
                   p.setProperty("Autocommit","Off");
                   p.setProperty("CursorType","Forward Only");
                   String ps=getPropertiesAsString(p);
              Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
                   conn=DriverManager.getConnection("jdbc:polite:whatever"+ps);
                   execSql(conn,
                        "drop table test1 cascade"
                   execSql(conn,
                        "create table test1(pk number(32),ncol number(32),scol varchar2(2000),dcol date,rcol long raw)"
                   conn.commit();
                   execSql(conn,
                        "insert into test1(pk,ncol,scol,dcol,rcol) values(?,?,?,?,?)",
                        new Object[]{new Integer(1),new Integer(1111),"Test Text",new java.sql.Date(System.currentTimeMillis()),new byte[]{0,1,2,3,4,5,6,7,8,9,10}}
                   conn.commit();
                   readSql(conn,"select * from test1");
              catch(Exception e){
              e.printStackTrace();
              finally{
                   if(conn!=null){
                        try{
                        conn.close();
                             conn=null;
                        catch(Exception e){e.printStackTrace();}
         private static String getPropertiesAsString(Properties p){
              StringBuffer buf=new StringBuffer();
         for(Iterator it=p.keySet().iterator();it.hasNext();){
              String key=(String)it.next();
                   String val=p.getProperty(key);
                   buf.append(";"+key+"="+val);
              return buf.toString();
         public boolean execSql(Connection conn,String s){
              return execSql(conn,s,(Collection)null);
         public boolean execSql(Connection conn,String s,Object[] binds){
              ArrayList list=new ArrayList();
              if(binds!=null) list.addAll(Arrays.asList(binds));
         return execSql(conn,s,list);
         public boolean execSql(Connection conn,String text,Collection binds){
              PreparedStatement stm=null;
              try{
                   stm=conn.prepareStatement(text);
                   if(binds!=null){
                        int i=1;
                        for(Iterator it=binds.iterator();it.hasNext();){
                             Object o=it.next();
                             if(o==null){
                                  stm.setNull(i,Types.VARCHAR);
                             else if(o instanceof byte[]){
                                  stm.setBytes(i,(byte[])o);
                             else{
                                  stm.setObject(i,o);
                             i++;
                   boolean b=stm.execute();
                   System.out.println("status: "+(b?"ok":"failed"));
                   return b;
              catch(SQLException e){
                   System.out.println("status: "+"error"+" "+e);
                   return false;
              finally{
                   if(stm!=null) try{stm.close();}catch(Exception e){}
         public boolean readSql(Connection conn,String text){
              PreparedStatement stm=null;
              try{
                   stm=conn.prepareStatement(text);
                   ResultSet rs=stm.executeQuery();
                   ResultSetMetaData meta=rs.getMetaData();
                   System.out.print("col: ");
                   for(int i=1,n=meta.getColumnCount();i<=n;i++){
                        System.out.print(""+meta.getColumnName(i)+", ");
                   System.out.println();
                   while(rs.next()){
                        System.out.print("row: ");
                   for(int i=1,n=meta.getColumnCount();i<=n;i++){
                             System.out.print(""+rs.getObject(i)+", ");
                        System.out.println();
                   return true;
              catch(SQLException e){
                   System.out.println("status: "+"error"+" "+e);
                   return false;
              finally{
                   if(stm!=null) try{stm.close();}catch(Exception e){}
         static public void main(String[] args) {
              TestOracleLite t=new TestOracleLite();
              t.start();
              t=null;
              System.exit(0);

    Hi
    After system copy you need to do post system copy activities...
    Please follow according to the installation Guide..
    for example: your sld connection of your new system will be pointing to your source system. So you need to go to VA where in you can find SLD Data Supplier and change the host name, port no relavent to this  i.e. your destination system...i.e.
    new system.. In the same way you can follow doing the post installation activites will solve your issue.
    Regards
    Hari

  • NoClassDefFoundError after System.exit() is called.

    I have found a strange condition with JDK 1.4.2_05 and could not find a bug which relates to it.
    I have multiple threads running, when I shutdown, I call all the threads to shutdown and finally in main I call System.exit(0).
    The strange thing is that one shutdown I get a NoClassDefFoundError for a class which will load fine if loaded before shutting down.
    This occurs as the class in question is only needed to perform a shutdown, and in fact the attempt to load it comes after the main thread has finished.
    The workaround has been to create an instance of the class when the application is started rather than during shutdown.
    Does anyone seen this behaviour?

    java.lang.NoClassDefFoundError: com/cantor/framework/run/impl/ShutdownRMB
         at com.can.framework.run.RunnerManagerBean.shutdown(RunnerManagerBean.java:147)
         at com.can.framework.layer.VanillaBean.shutdown(VanillaBean.java:278)
         at com.can.main.Main.main(Main.java:135)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)

  • [SOLVED] how to keep urxvt / xterm scrollback after ssh exit

    Hey Guys,
    Would really appreciate some help.  How do you keep the scrollback history in urxvt after exiting a ssh session?  After closing the SSH session it appears to do a reset (the inital ssh command is not even shown, but all command prior to ssh are still in scrollback).  xterm does the same thing, but terminator keeps the scrollback after exit.
    [Unit]
    Description=RXVT-Unicode Daemon
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    User=%i
    ExecStart=/usr/bin/urxvtd -q -f -o
    [Install]
    WantedBy=multi-user.target
    URxvt*font:                     xft:Ubuntu Mono-12
    URxvt*boldFont:                 xft:Ubuntu Mono-12
    URxvt.talicFont:                xft:Ubuntu Mono-12
    URxvt.bolditalicFont:           xft:Ubuntu Mono-12
    URxvt*letterSpace:              -1
    Urxvt.depth:                    32
    URxvt.colorDB:                  white
    URxvt.colorIT:                  #87af5f
    URxvt.colorBD:                  #d7d7d7
    URxvt.colorUL:                  #87afd7
    URxvt*termName:                 xterm-256color
    URxvt.urgentOnBell:             True
    URxvt*saveLines:                32767
    URxvt*scrollBar:                false
    URxvt*scrollBar_right:          false
    URxvt*skipScroll:               false
    URxvt*jumpScroll:               true
    URxvt*loginShell:               true
    URxvt*fading:                   20
    URxvt*secondaryScroll:          true
    URxvt*visualBell:               true
    URxvt.perl-ext-common:          default,keyboard-select,url-select,selection-to-clipboard
    -J
    Last edited by V31GN (2014-08-06 20:45:22)

    Glad you got it sorted: please use code tags when pasting ot the boards
    https://wiki.archlinux.org/index.php/Fo … s_and_Code

  • Post processing steps after system copy

    Hi experts,
    Please clarify the doubts, reg my situation,
    We don have our development server in synchronous with production server, so we destroyed the existing development client and copied the production client, now the new system logical name  in sm30 in table T000 is MABCLNT900 and also our production server is same,as we copied it from production server, previously our development server was with MAACLNT495 which was mapped with MAQCLNT500 , R3 test sytem,
    in this scenario we want run BDLS tool to change client name in both R3 and BW , Please explain step by step procedure in achieving this,
    Thanks in advance

    Hi,
    As I understood your system landscape should look like this:
    BW DEV (MAACLNT495) <-> R3 DEV (MAQCLNT500)
    BW PRD (MABCLNT900) <-> R3 PRD (???)
    After BW system copy you should change connections in SM59 and then use BDLS to change logical system name.
    You can also use Restore function for source systems (RSA1).
    Although if you copy both R/3 and BW systems at the same time it's possbile just to keep the same logical system names as they are in productive (it's easier to maintain).
    Please read notes: 886102, 543715, 325470, 325525, 184322, 886102, 184971, 184447, ...
    regards
    Krzys

  • Socket alive after program exit

    The java socket connection remains alive when the the program exits abrubtly. No exception is thrown at the listening socket side. Since timeout is set, InterruptedIOException is thrown at timeout intervals.

    Is there a question?
    That doesn't have anything to do with java. That is how TCP/IP works.
    The only way to detect all connection failures is to write to the socket - reads will not do it.

  • How to call external processes before & after WL services start/stop

    I set up WL Admin Server and Managed Server to run as Windows services.
    I have the code to retire/re-activate in an ANT script and right now, I execute it via the command line.
    Here's my question
    I want to retire a SOA composite BEFORE my Managed Server Windows service stops and re-activate it AFTER the Window service starts up.
    Do you know how to do that? Or if you have other suggestions, please let me know
    Thanks
    I'm using 11.1.1.2

    I want to retire a SOA composite BEFORE my Managed Server Windows service stops and re-activate it AFTER the Window service starts up.
    This means you need to check for the ManagedServer is in RUNNING state right?
    in WLST you can get State of a given Managed Server with getState() method. write a WLST invoke method in ANT and try.

  • Accounting document not copied after system copy.

    Hi,
    We copied the production system into our test system using backup/restore.  In the post copy verification, our CO team complained because they could not see the "accounting documents".
    What do you think happened why the accounting document was not copied?
    thanks
    krbas

    Hi Krbas,
    Make sure you did all the post processing activities after system copy. I doubt you missed some post processing activities related to CO after your system copy.
    regards,
    VInodh.

  • Kill and System.exit

    Is there a way (with Linux) to issue the kill command on your java process so that System.exit(0) is called and you know that your shutDownHooks will run?

    Thanx again for the reply, Freddy
    first things first:
    System.exit(0) does not work in this case..
    and the code is reached..
    // main class
    public class AdminApp {
    public AdminApp() {
    public static void main(String[] args) {
    AdminApp adminApp1 = new AdminApp();
    AdminFrame frame = new AdminFrame();
    /// admin frame class
    public class AdminFrame extends JFrame{
    public AdminFrame() {
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    this.pack();
    this.setSize(600,480);
    this.setVisible(true);
    groupsMenuItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    desktop.add(new AdminGroups());
    //admingroups class
    public class AdminGroups extends JInternalFrame {
    private JTextArea textArea = new JTextArea();
    private JScrollPane scrollPane = new JScrollPane();
    JPanel groupPanel = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    public AdminGroups() {
    setSize(200,300);
    setTitle("Edit Text");
    setMaximizable(true);
    setIconifiable(true);
    setClosable(true);
    setResizable(true);
    scrollPane.getViewport().add(textArea);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(scrollPane,BorderLayout.CENTER);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    getContentPane().add(groupPanel);
    private void jbInit() throws Exception {
    groupPanel.setLayout(xYLayout1);
    }

  • I keep getting this message after closing Firefox and attempt to reopen-Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

    I keep getting this message after closing Firefox and attempt to reopen-Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

    See:
    * http://kb.mozillazine.org/Recovering_a_missing_profile
    * http://kb.mozillazine.org/Profile_in_use

  • Firefox 29.0.1 leaves process running after exit, which must be terminated manually before Firefox will re-start.

    After updating to Firefox 29.0, firefox.exe *32 process keeps running after application exit, and must be terminated manually before Firefox will re-start. The update to 29.0.1 did not solve the issue. All updates prior to 29.0 never exhibited this problem, and there have been no other changes to my system, so this issue originated with 29.0.

    Thanks for the response, and you are right, for now the only one being helped by leaving telemetry on is me, because there is (apparently) no problem to report when it is on.
    Slight clarification:
    1. Enabling history and cache fixes problem.
    2. Enabling telemetry fixes problem.
    3. Enabling history and cache, cycling FireFox on/off, then disabling history and cache, fixes problem during current power cycle, but not persistently between power cycles.
    4. All the above settings do persist across power cycles.

  • Project system; external processing costs flow in cn41?

    Dear PS gurus,
    Kindly help in giving solution how to activate/get the costs flown materialwise or services in external processing of network.
    in CN41, costs in External processing of Newtork are flown at header level is., material level or Service level only. but line items of materials or services are coming in report (cn41), the values of planned costs or actuals costs are not flowing in line itemwise.
    pl help
    Thanks & regards
    Srihari

    Hi pp,
    we make pr- thru network only in external processing for material/service.
    eg; in ext. processing purchase materials -
    >
    in component overview i give material 1 - rs. 10
    material 2 - rs. 20
    pr is created per line itemwise and two pos made or single po
    in cn41, we get only
                                          planned costs  actual costs
    purchase maetrials               30                    30 (after migo-gr)
    material 1                             0                       0
    material 2                             0                       0
    my requirement, how i can get Rs. 10 for material 1
    Rs. 20 for material 2
    hope i have clarified, pl let me know how i can get values line itemwise either materials or services.
    pl note pr material is line itemwise only
    regards
    regards

Maybe you are looking for

  • Old PC Broke - cannot access itunes. New PC - how do I get my itunes back and will i damage my iphone?

    My PC has broke (completely gone) and I bought a new one which is now up and running - how can i access my itunes? I have all my apps and itunes on my iphone4 (but this is out of date at 4.3.5 (8L1) ) so as i cannot access my old pc am i at risk of l

  • BTE to substitute BSEG-BZDAT in MIRO doesn't work

    Hi all, I need to substitute the field BSEG-BZDAT with BKPF-BLDAT in all asset invoices postings through MIRO, in order to get the correct value date in AM for  depreciation calculation. After set a breakpoint in function module BF_FUNCTIONS_FIND, I

  • Convert physical standby to logical

    Hi everybody!! This is my first message on this forum, altought i have been reading few time before (around 4 months) I have a "problem" in my database environment. I must change a physical standby to a logical standby. This cahnge is possible with d

  • Why is the first MIDI note always delayed?

    Hi all I'm having some trouble recording MIDI in Logic Pro X. When using virtual instruments (built-in Logic instruments) there is a latency issue with the first note. When recording or playing along, the first note I play has quite audible latency,

  • Outputting XML to Excel

    Hey all, So I have a page that uses a cfheader and cfdontent tag to open an Excel doc and I transform an XML item with XMLTransform() to the XML format for Excel. When I have debugging turned off it works fine. When I turn debugging on thought I get