dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: invoke a process from main program and exit the main program

  1. #1
    Join Date
    Dec 2010
    Posts
    1

    invoke a process from main program and exit the main program

    My requirement is from the main java program, I need to invoke another program on unix platforms and once this process is invoked, main program should exit.

    But the problem I see is, before the sub program gets launched or invoked, the main program is exiting.

    How to resolve this issue elegantly?

    For time being I used Thread.sleep() for some amount of time in main program.

    But the sleep amount could vary from system to system depending on the load.

    If I use process.waitFor(), the main program waits till the end of sub program-- which I dont want.

    Thanks in advcane for any help or guidence in this direction.

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: invoke a process from main program and exit the main program

    You can't launch the program directly if you want the Java program to exit before the launched program completes. You need to launch a native process that creates a new process to run the application. Not sure how you do it on unix but I think you can do it on windows by launching a command shell and executing the 'start' command. There's bound to be something on unix to do something similar to this.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)