Runtime.exec() then kill parent process, then you lose the System.out

If I do this:
in Proggie 1:
Process proc = Runtime.getRuntime().exec("proggie");
System.exit();in Proggie 2:
System.out.println("some string"); // goes nowhere??How can I redirect Proggie 2 System.out to the console that was used to start Proggie 1?

How can I redirect Proggie 2 System.out to the
console that was used to start Proggie 1?No way with current Java. This is a long and sad story that Java does not have i/o redirection. See for example one of the entries in the bug database:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4960438
Harald.
http://www.ebi.ac.uk/Rebholz-srv/whatizit/software

Similar Messages

  • Executing jar from java code, then kill parent java code

    Please suggest if there is any best way around on executing jar from java code then killing parent java code.
    a) I have desktop based java application say "Monitor.java" which runs every 5 minutes.
    b) How can I START external java application say "execute.jar" from Monitor.java THEN EXIT Monitor.java
    I tried various options using "ProcessBuilder" and calling bat file but I need Monitor (parent application to EXIT, immediately after calling child (execute.jar)
    Try1) ProcessBuilder builder = new ProcessBuilder("java -jar execute.jar");          
    Process process = builder.start();
    Try2) Runtime r = Runtime.getRuntime();
    Process p = null;
    p = r.exec(new String[] { "cmd", "/c", "start C:/temp/Test.bat" });

    I have a requirement to transfer data from one db to another db from Java Application Layer.Maybe, maye not. We get all sorts of weird "requirements" - which are nothing but thoughts or proposed solutions.
    But,
    Did the "requirement" mention whether the table existed already or not in the target database? - If not, did it tell you to create it - drop/create it?
    Did the "requirement" deliver some explanation to why this copying was neeeded? - Are we talking replication? - Or a one time cloning?
    Etc, etc,
    Personally I would always argue against a "reuirement" like that. - It just isn't the way to do it. Period.
    Regards
    Peter
    P.S: If you are satisfied with what COPY does, then you could let Java make an OS call and do it from there?

  • In Exports sales process, how you configure the Duty Draw Back

    in my case
    we r creating Exports but
    duty unavailability of time and time taking process in export processing
    we are creating Excise invoice and cenvat is debited .
    now we r asking the govt. for the duty draw back for the value already cenvat is debited with proper documents like ARE1 etc.
    how to manage this duty back and what r the replications or changes thereafter
    thanks in advance

    Hi Sunitha,
    Pls can u explain how did u solve (In Exports sales process, how you configure the Duty Draw Back) this issue....since i don't have idea abt this...but shortly i am going to do this in my client place....
    thanks,

  • HT1529 I have multiple users on my Mac and I was wondering how you tell the system to retain all the user names so they don't have to enter their email addresses every time ???

    I have multiple users on my Mac and I was wondering how you tell the system to retain all the user names so they don't have to enter their email addresses every time ???

    Email addresses into what?
    Each user should have their own account and password to log in.  Each is independent of the other.  So for Mail each has their own Mail account if they set one up in Mail. 
    That's the way it should be set up.  Are you using a single account and allowing multiple users to use that one single account?  If so then in Mail at least you could set up individual mail accounts.  But everything else in the system is shared.

  • Job also cancelled due to process termination. See the system log

    Hi Friends,
    I am working Interface Programs in HCM Module.
    My problem is when i am Executing my program in BACKGROUND .After some time my job is canceling. In log i am  getting message
    "Job also cancelled due to process termination. See the system log"
    when i see that system log also i am unable to find any thing.
    but in fore ground is working fine .
    Please help me  .
    Thanks in Advance..
    Regards,
    Kumar...

    Hi,
    You need to check that program in debugging for the Backgournd process.
    For doing the debugging of the background process do the following steps.
    1)go sm37 and select your job.
    2)in the command line just type JDBG (not the /nJDBG OR /oJDBG) and hit enter. it goes to the debuggin mode.
    Thanks

  • How do you manage photos if you lose the computer your iphone was synced with?

    how do you manage photos if you lose the computer your iphone was synced with?

    Are you talking about photos that were synced to your phone? If so, the photo sync is one-way: Computer to phone. Apple makes no provision to extract these photos from your phone, you'll have to use third-party software to do so. Note: photos synced to your phone were reduced in resolution for display on your phone, there is no way to recover their full resolution.
    http://www.wideanglesoftware.com/touchcopy/index.php

  • When you upgrade from iPhoto '09 to iPhoto '11 will you lose the photos in the old iPhoto '09 library

    When you upgrade from iPhoto '09 to iPhoto '11 will you lose the photos in the old iPhoto '09?

    You won't lose data because it's updated for iLife '11

  • If you uninstall & reinstall itunes on a pc do you lose the music library

    If you uninstall & reinstall itunes on a pc do you lose the music library

    ...but backup anyway.
    tt2

  • Can you take the shaking out of a video?

    Can you take the shaking out of a video on the iphone 4?

    Yes you can.
    Cheers,
    George
    In daily use: R60F, R500F, T61, T410
    Collecting dust: T60
    Enjoying retirement: A31p, T42p,
    Non-ThinkPads: Panasonic CF-31 & CF-52, HP 8760W
    Starting Thursday, 08/14/2014 I'll be away from the forums until further notice. Please do NOT send private messages since I won't be able to read them. Thank you.

  • Dear Apple, Have you fixed the 'Time out' issue with airport? It now happens to me 2-3 times a day for the past 6 months. Answers please.

    Dear Apple, Have you fixed the 'Time out' issue with airport? It now happens to me 2-3 times a day for the past 6 months. Answers please.

    We're not Apple - these boards are user-to-user.
    Your profile says 10.7.3 - try applying the 10.7.5 combo update.

  • Runtime.exec() and fork() and Process

    So let me see if I understand this correctly, and if I don't please fill me in. If I call the following piece of codeRuntime.getRuntime().exec("chgrp rcsweb " + path+fs+orgName);
    Runtime.getRuntime().exec("chmod 660 " + path+fs+orgName);where path is the real path to a file, fs is short for File.spearator and orgName is the name of a file, then in the Unix environment, it will fork off a process.
    First, I seem to remember one forum topic that mentioned not forgetting about killing the process returned by exec, so I guess I need to add that to my code.
    Second, since I am forking off this process inside of a J2EE container, am I actually forming off the entire container, or just the Servlet where Runtime is called, or what?
    Third, how can I prevent the error java.io.IOException: Not enough space
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:54)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:546)
    at java.lang.Runtime.exec(Runtime.java:413)
    at java.lang.Runtime.exec(Runtime.java:356)
    at java.lang.Runtime.exec(Runtime.java:320)when I do not have the option of changing my VM size? Is killing the Process (and using waitFor()) going to take care of this issue?
    I appreciate your help.

    OK, after writing a few test programs, it is indeed clear..on unix (at least on solaris) when calling runtime.exec(..) The ENTIRE VM does indeed get forked. Therefore if your current Memory allocation for you VM is sitting at say 64MB (or you initial memory setting), another 64MB process will be created, even if you doing something as a simple
    exec("ls");
    I also tried putting runtime.exec call in its own thread hoping that if it was not in the main thread, that only that process would be forked..to no avail..the entire vm is indeed forked everytime...making runtime.exec damn near useless for server side work, and very dangerious..as you can essentialy assume you always need 2x your memory requirements.
    If anyone has figured out a workaround...any suggestions greatly appreciated.
    Some thoughts on some work-arounds
    1. Run 2 VMs (then when native calls are required..send a message to the 'native-calling vm' (insure its memory footprint is very low)
    2. Write your exec method via JNI (or does JNI calls also result in a fork of the vm on unix..)
    Test code below (threaded version)
    import java.util.*;
    import java.io.*;
    public class test5 extends Thread
         public void run()
              int loops = 0;
              while (true)
                   loops++;
                   System.out.println("---- iteration " loops "---");
                   makeNativeCall();
         public static void main(String[] args)
              try
                   System.out.println("testing on OS: " + System.getProperty("os.name"));
                   // Allocate a nice chunk of memory
                   byte[] bytes = new byte[1024 * 1000 * 50];
                   test5 tst = new test5();
                   tst.start();
                   while (true)
                        Thread.sleep(1000);
         catch(Exception e)
         {e.printStackTrace();}
    public void makeNativeCall()
              Runtime runtime = Runtime.getRuntime();
    InputStream stderr = null;
    InputStream stdout = null;
              OutputStream stdin = null;
    Process proc = null;
    long totalMem = (long)(runtime.totalMemory()/1024);
    long freeMem = (long)(runtime.freeMemory()/1024);
    long usedMem = (long)((totalMem - freeMem));
    System.out.println("VM REPORT: TOTAL(" totalMem") FREE("+freeMem+") USED(" usedMem")" );
    try
    proc = runtime.exec("sleep 1");
    stderr = proc.getInputStream();
    stdout = proc.getErrorStream();
    stdin = proc.getOutputStream();
    String line = null;
    int i = 0;
    String error = "";
    int exitVal = proc.waitFor();
    if (exitVal != 0)
    System.out.println("ERROR " +exitVal);
    System.out.println("DETIAL" +error);
    catch(Exception e)
    e.printStackTrace();
    finally
    if (stderr != null)
    try{stderr.close();}catch(Exception ignore){ignore.printStackTrace();}
                   if (stdout != null)
    try{stdout.close();}catch(Exception ignore){ignore.printStackTrace();}
                   if (stdin != null)
    try{stdin.close();}catch(Exception ignore){ignore.printStackTrace();}
    if (proc != null)
    try{proc.destroy();}catch(Exception ignore){ignore.printStackTrace();}

  • Problems with Runtime.exec() and certain Unix processes

    Certain Unix processes don't behave correctly when run from Java using Runtime.exec(). This can be seen by running /bin/sh and trying to interact with it interactively. The issue appears to be that /bin/sh (and many other Unix tools) are checking the file handles on the spawned process to see if they are associated with a TTY.
    Is there any way to associate a process spawned by Runtime.exec() with a terminal or alternatively, is there a JNI library available that would setup the process correctly and still provide access to the input and output streams?
    Our objective is to have the flexibility of expect in being able to run and interact with spawned processes. A bug was opened at one point but closed back in 1997 as being a fault in the spawned process, not Java.
    Bug ID: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4058689

    #include <stdio.h>
    void doit() {
    int c;
            while((c=getc(stdin)) != EOF) {
                    printf("%c",c);
    int main() {
            freopen("/dev/tty", "r", stdin);
            doit();
    }This program reopens its standard input against /dev/tty and catenates it to stdout. And voila, it takes its standard input from the terminal, even though it was started with stdin against /dev/null..
    $ gcc b.c -o b
    $./b < /dev/null
    buon giorno
    buon giorno

  • How can I know if a process is running in the system???

    Hello all,
    I generate a pdf file with Reports Builder called from Forms Builder.
    This pdf is printed in the default printer with the command line "start AcroRd32.exe /p /h path_file", inside host command, which open the Acrobat Reader and prints the document in the default printer.
    After the document is printed the document is closed but not the Acrobat Reader program.
    I need an instruction to know if the acrord32.exe is running in the system.
    Could anyone help me?
    Thank you very much for advance,
    Jordi

    do you use the commandline, because you want to print directly to your default-printer?
    then have a look at the orarrp - toolset on otn.
    It's a technique, which directly prints via MIME-extensions of your browser. Internally Adobe is used for this direct print, but you only have to install a little program on your client.
    try it
    Gerd

  • Can you listen to System.out ?

    Good morning form. Is there a way to listen to System.out?
    This could be useful in testing. You could compile a test version of the app and report all Sys out activity then turn it of in production (or not). The point would be to be able to apply this to applications after they were written. (as in not a consideration at the time the app was written).
    I know if the app is run from a command line you can pipe the output to a file.
    Thanks
    ST

    Good morning form. Is there a way to listen to
    System.out?
    This could be useful in testing. You could compile a
    test version of the app and report all Sys out
    activity then turn it of in production (or not). The
    point would be to be able to apply this to
    applications after they were written. (as in not a
    consideration at the time the app was written).
    I know if the app is run from a command line you can
    pipe the output to a file.
    Thanks
    STHi, you should use logging instead. E.g. Log4J or java.util.logging

  • Changing a folder name means you lose the icon?!

    that's nuts.
    i hate sports so i changed the 'sports and entertainment' to 'entertainment' and i lost the lil' icon on that folder. now it's an empty blank lookign folder. how annoying. did i f it up for good? any ideas on how to get it back short of pressing the 'reset all icons' or something liek that that i saw which leads me to think it will defualt the ENTIRE home screen to how it was when i frist received it?
    aargh!  

    Hi and welcome to the forums!
    Was this folder provided by the carrier or a folder you created?
    If it's carrier specific changes are it will be recreated when you reregister the phone and resend service books.
    Try this:
    Go to options advanced options, Host Routing Tables, click to enter. DO NOT click on any listing.
    Press menu key, and select register now.
    You will get a verification message. Then go to email settings and send service books.
    You will get an email per account. Once complete, check all folders to see if it has returned.
    Personally I do not use the majority or the vendor apps. I create a folder for all the applications I do not use.
    I place all the icon in it, hide the icons, and then hide the folder. This was I get a clean desktop and I don't
    accidentally starts an unwanted app. I do the same with all the email icons for accounts. I just use the main message queue.
    Let me know if this is what you were asking.
    Thanks,
    Bifocals
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

Maybe you are looking for

  • Problem in record counting?

    Hi,   I want the total number of records displayed in the output of the report in an horizontal manner. Those values are obtained by giving range. for example:   company codes                                      total 0001|0002 |0003|               

  • How to insert checkbox at a particular  cell  in jtable

    hello, I am a user of jdeveloper using jclient/swing . question: i am using jtable. i want that whenever i click on a specified cell then text at that particular cell get clear and a checkbox inserted in that cell . whenever i click on that checkbox

  • MIS report extraction for P&L and B/S  t codes

    Hi MIS report required from SAP for the following: 1. Profit & loss acct (consolidated , plant and segment wise) 2. Balance sheet we havn't configured FSV at production yet, so without this is it possible? Edited by: barnabasjh on Jul 7, 2010 12:50 P

  • Interesting Lync client "Bug" with Timezones with Fix.

    Running Lync Client v4.0.7577.4087 User called stating he was unable to log into Lync and was getting a message about the Clock on his PC being wrong.   He verified his time was correct but continued to get the error. I looked at the machine, he live

  • Sap/hr/ number  range

    FOR HIRING PERMANENAT EMPLOYEES I WANT TO USE 1 RANGE . IT IS UNCHECKED . EG. I WANT TO MAKE NEW HIRING there are already 5 intervals for different category in transaction pa04 . In this case for hiring (pa40) per. no should start from 0000003352 NO