Runtime.exec() + getOutputStream() +write+me program=hang

I'm trying to write to the standard input of an external prorgram by using Runtime.exec() and writing to the outputstream of the process it creates. I write to the standard in and then wait for that process to finish using waitFor() but it just hangs there. Is there something special to do before writing the data?
There is nothing funky about my code, it's just basic stuff.
OutputStream out =process.getOutputStream();
out.write(data);
out.flush();
out.close();
process.wairFor();

Do you really know
1. That the process got the data and processed it?
2. That the process exited and you are still hanging?
Sorry if I'm just stating the obvious, but is the other process perhaps waiting for an end-of-line or end-of-input?
Finally, you didn't say what the other process technology is, but I've had some surprises when attempting to work between java and other technologies. Example: Other process was LEX, which uses a Windows flag to check for character or block input. Flag was set in a surprising manner when java was the source, and my LEX blocked forever.

Similar Messages

  • Runtime.exec child process - C program, I/O blocked???

    Hi i'm meeting this interesting problem. I am running a simple C app from a Java app as a child process. I want to read/write both the Input and Output before the child process is finished but especially the output of the C app seems to be bloked before the process is finsished and thus i can not make any dialogue with the app when needed?
    Any ideas...., here's the source
    try
    String[] command={"cmd","/c","prog.exe"};
                   Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command);
    InputStream stderr = proc.getInputStream();
    /*String str="123";
    BufferedOutputStream bufStr= (BufferedOutputStream) proc.getOutputStream();
    bufStr.write(123);
    bufStr.flush();*/
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null)
    System.out.println(line);
    PrintWriter out = new PrintWriter(new OutputStreamWriter(proc.getOutputStream()), true);
    out.write("qwer");
    out.flush();
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    } catch (Throwable t)
    Another thing - when it reaches to reading the output of the C app , the execution of main is suspended and it hangs indefinitely....?
    thanks a lot , it really bugs me.....

    As for
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-
    traps.html?page=4 ,
    i have read it a couple of times and digested it:),
    tryed a couple of things but i can't say anything
    there solves my problem. If you have anything
    particular in your mind please, please specifuy or
    quote in the post....How can I ! You don't show your latest code and your original code needed changing so that it implemented the guidelines in the reference.
    >
    And one more thing , i am pretty sure that the
    problem is in the fact that the .exe prog blocks its
    out stream until finishing, i'm working on why and
    how to undo it....Since I don't have access to the source code of your exe and I don't have the source code of your java and I don't have your problem with executing any of my exe files then I can't comment. And, yes my exe files do write to stdin, read from stdout and read from stderr. I also use the same approach with perl and python scripts.

  • Strange problem when a c++ program is triggered by Runtime.exec()

    I am working in linux system. I have 2 programs:
    1. one is a c++ program e.g. AAA. In this program, i use "system("gcc ...")" to call gcc to do some internal processing
    2. the other is a java program BBB. In this program, i use Runtime.exec("AAA") to run program AAA.
    case 1
    if I run c++ program AAA directly, everything goes well, gcc call via "system" is successful.
    case 2
    if I run java program BBB to trigger AAA indirectly, the AAA can be executed, but the system call (gcc call inside AAA) is failed.
    so, what is wrong? any hints? what is the solution to make case #2 work? I just want to use BBB to trigger AAA, and the system call should also be successful.
    thanks in advance for your help!

    "...but the system call (gcc call inside AAA) is failed."
    Isn't terribly descriptive, but I'm guessing that it complains it can't find gcc?
    If that's the case then it's because the call to Runtime.exec() runs the code in a shell with no idea where anything is, whereas when you run the C++ code straight it is running in the shell you kicked it off in. Something along those lines anyway.
    Someone else'll be able to tell you how to get it to work. I'm sure I've seen this sort of problem here several times.

  • How to capture output from Runtime.exec() ?

    Hi,
    Well, the question is in the subject ...
    I'd like to capture the output of a process ran by Runtime.exec() in order to process it.
    thanks,
    ionel

    Okay ...
    Sorry for the post !
    I found the solution : Runtime.exec().getOutputStream()
    Thanks however
    ionel

  • Problem in Runtime.exec()

    I am trying to launch a new java application from my java program like this-:
    import java.io.*;
    public class test123{
    //String userStr="";
                public static void main(String args[]) throws Exception{
                        Process p = Runtime.getRuntime().exec("java JavaExec",null,currentDir);
                        Thread.sleep(10000);
                        System.out.println("After Destroy");
    } The JavaExec file�s code is -:
    import java.io.*;
    import org.apache.log4j.Logger;
    public class JavaExec
                 static Logger logger = Logger.getLogger("JavaExec.class");
    public static void main(String args[])
    try
                Runtime runtime = Runtime.getRuntime();
                            Process process = runtime.exec("notepad");
                int exitCode=0;
                while(true)
                            //logger.info("Inside the infinite while loop in javaexec");
                            try
                                        exitCode = process.exitValue();
                                        System.out.println(exitCode);
                                        process.destroy();
                                        process = runtime.exec("notepad");
                            catch(IllegalThreadStateException itse)
                                        System.out.println("Inside exception");
    } catch (Throwable t)
    t.printStackTrace();
    }Notepad opens when I execute the test123 class but instead of remaining open even if I close it , I am able to close notepad. The JavaExec only starts processing again when my main quits.
    Please let me know the solution to this problem.....
    Thanks in Advance
    Inder Jeet Singh

    Convoluted at best. You don't need that loop, just useexitCode = process.exitValue();and it will block until notepad exits.
    P.S. Why a Runtime.exec() executing a Java program that does a Runtime.exec() on notepad?

  • Runtime.exec() output

    I'm using Runtime.exec() to run a program from within my Java application, but I can't seem to get any of the output from it. I can get the output of some commands, like 'ls' using Process.getInputStream(). Other commands execute , but I don't catch their output. Why can I catch some output, but not other's?
    I'm using Linux, if that makes a difference
    Tyler Ryan

    Also, while playing around with things, I realized the
    process is running native to the directory that my
    program is in (makes sense, but I just hadn't thought
    about it). Is there a way to make the process run
    native to another directory?Do you mean have it start in a different directory than where your process started? Sure, look at the other exec() methods that take different parameters. A couple of them take a File parameter to tell it what directory to start in.

  • Runtime.exec() hangs with 1.4.1

    Hello altogether,
    I am trying to execute a command with Runtime.getRuntime.exec()
    I have already taken care of capturing the output and I observe that depending of the program I try to execute the process hangs.
    I am using JRE 1.4.1_02 under Redhat 7.2 with kernel 2.4.18-26
    Executing the same program under JRE 1.3.1 the program does not hang.
    Executing 'top -bn0q' hangs, executing 'ls -als' it hangs.
    Here is my sample code:
    <code>
    import java.io.*;
    public class Exec
    /** catches the output in a parallel thread */
    class StreamReader extends Thread
    String category = null;
    InputStream is;
    StreamReader(String category, InputStream is)
    this.category = category;
    this.is = is;
    public void run()
    try
    System.out.println(this.category+": reader runs");
    InputStreamReader isr = new InputStreamReader(this.is);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while (br.ready() && (line = br.readLine())!=null)
    System.out.println(this.category+':'+line);
    catch (Exception e)
    e.printStackTrace();
    public void run(String[] cmd)
    StringBuffer outStrBuf = new StringBuffer();
    try
    Runtime rt = Runtime.getRuntime();
    System.out.println("got runtime");
    Process process = rt.exec(cmd);
    System.out.println("fired cmd");
    // any errors
    System.out.println("prepare error stream");
    StreamReader errSr = new StreamReader("ERR",process.getErrorStream());
    // any output
    System.out.println("prepare output stream");
    StreamReader outSr = new StreamReader("OUT",process.getInputStream());
    // start the readers to read
    System.out.println("start readers");
    errSr.start();
    outSr.start();
    System.out.println("waiting for process to end");
    process.waitFor(); //Waits for the subprocess to complete.
    catch (Exception e)
    System.err.println("Error while executing cmd: " + cmd);
    e.printStackTrace();
    System.out.println(outStrBuf);
         public static void main(String[] args)
    String [] cmd = {"top","-bn0q"};
    if (args.length >= 1)
    cmd = args;
    System.out.println(args[0]);
    Exec exec = new Exec();
    exec.run(cmd);
    </code>
    The output of java Exec is:
    [user]$ java Exec
    got runtime
    fired cmd
    prepare error stream
    prepare output stream
    start readers
    waiting for process to end
    OUT: reader runs
    ERR: reader runs
    ...and there it hangs. Interesting is, that when I use ls -als as command, I get the directory listing.
    Do you have any ideas what I am doing wrong? Is there any difference in the Runtime.exec() between 1.3 and 1.4 version?

    Unbelievable and what a shame. I was hacking 2 days on several variations of this problem and the solution and I finally found one difference:
    while (br.ready() && (line = br.readLine())!=null)
    I assume that when executing the command, the output streams are not ready and my Output gobbler threads end.
    ...however the command is still executing and starts to write its output. And as we all know this will overflow the buffer and the process hangs.
    So the final solution is:
    /** catches the output in a parallel thread */
    class StreamReader extends Thread
      String category = null;
      InputStream is;
      StreamReader(String category, InputStream is)
        this.category = category;
        this.is = is;
      public void run()
        try
          System.out.println(this.category+": reader runs");
          InputStreamReader isr = new InputStreamReader(this.is);
          BufferedReader br = new BufferedReader(isr);
          String line = null;
          while (/**br.ready() &&*/ (line = br.readLine())!=null)
            System.out.println(this.category+':'+line);
        catch (Exception e)
          e.printStackTrace();
    }So the only question that I have open: Why does this makes no problem with 1.3 but with 1.4 ?

  • Running java process in a while loop using Runtime.exec() hangs on solaris

    I'm writting a multithreaded application in which I'll be starting multiple instances of "AppStartThread" class (given below). If I start only one instance of "AppStartThread", it is working fine. But if I start more than one instance of "AppStartThread", one of the threads hangs after some time (occasionaly). But other threads are working fine.
    I have the following questions:
    1. Is there any problem with starting a Thread inside another thread?. Here I'm executing the process in a while loop.
    2. Other thing i noticed is the Thread is hanging after completing the process ("java ExecuteProcess"). But the P.waitFor() is not coming out.
    3. Is it bcoz of the same problem as given in Bug ID : 4098442 ?.
    4. Also java 1.2.2 documentation says:
    "Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock. "
    I'm running this on sun Solaris/java 1.2.2 standard edition. If any of you have experienced the same problem please help me out.
    Will the same problem can happen on java 1.2.2 enterprise edition.?
    class AppStartThread implements Runnable
    public void run()
    while(true)
    try
    Process P=Runtime.getRuntime().exec("java ExecuteProcess");
    P.waitFor();
    System.out.println("after executing application.");
    P.destroy();
    P = null;
    System.gc();
    catch(java.io.IOException io)
    System.out.println("Could not execute application - IOException " + io);
    catch(java.lang.InterruptedException ip)
    System.out.println("Could not execute application - InterruptedException" + ip);
    catch (Exception e)
    System.out.println("Could not execute application -" + e.getMessage());

    I'm writting a multithreaded application in which I'll
    be starting multiple instances of "AppStartThread"
    class (given below). If I start only one instance of
    "AppStartThread", it is working fine. But if I start
    more than one instance of "AppStartThread", one of the
    threads hangs after some time (occasionaly). But other
    threads are working fine.
    I have the following questions:
    1. Is there any problem with starting a Thread inside
    another thread?. Here I'm executing the process in a
    while loop.Of course this is OK, as your code is always being run by one thread or another. And no, it doesn't depend on which thread is starting threads.
    2. Other thing i noticed is the Thread is hanging
    after completing the process ("java ExecuteProcess").
    But the P.waitFor() is not coming out.This is a vital clue. Is the process started by the Runtime.exec() actually completing or does the ps command still show that it is running?
    3. Is it bcoz of the same problem as given in Bug ID :
    4098442 ?.
    4. Also java 1.2.2 documentation says:
    "Because some native platforms only provide limited
    ed buffer size for standard input and output streams,
    failure to promptly write the input stream or read the
    output stream of the subprocess may cause the
    subprocess to block, and even deadlock. "These two are really the same thing (4098442 is not really a bug due to the reasons explained in the doc). If the program that you are exec'ing produces very much output, it is possible that the buffers to stdout and stderr are filling preventing your program from continuing. On Windows platforms, this buffer size is quite small (hundreds of characters) while (if I recall) on Solaris it is somewhat larger. However, I have seent his behavior causing problem on Solaris 8 in my own systems.
    I once hit this problem when I was 'sure' that I was emitting no output due to an exception being thrown that I wasn't even aware of - the stack trace was more than enough to fill the output buffer and cause the deadlock.
    You have several options. One, you could replace the System.out and System.err with PrintStream's backed up by (ie. on top of) BufferedOutputStream's that have large buffers (multi-K) that in turn are backed up by the original out and err PrintStream's. You would use System.setErr() and System.setOut() very early (static initializer block) in the startup of your class. The problem is that you are still at the mercy of code that may call flush() on these streams. I suppose you could implement your own FilterOutputStream to eat any flush requests...
    Another solution if you just don't care about the output is to replace System.out and System.err with PrintStreams that write to /dev/nul. This is really easy and efficient.
    The other tried and true approach is to start two threads in the main process each time you start a process. These will simply consume anything that is emitted through the stdout and stderr pipes. These would die when the streams close (i.e. when the process exits). Not pretty, but it works. I'd be worried about the overhead of two additional threads per external process except that processes have such huge overhead (considering you are starting a JVM) that it just won't matter. And it's not like the CPU is going to get hit much.
    If you do this frequently in your program you might consider using a worker thread pool (see Doug Lea's Executor class) to avoid creating a lot of fairly short-lived threads. But this is probably over-optimizing.
    Chuck

  • Runtime.exec hangs even If I drain output.

    Hi Everyone,
    I'm trying to make a program that would give me access to a command line on a remote server. So what I'm trying to do is use Runtime.exec("cmd") to open a command line, then reading from it and printing to it normally.
    The problem is the same very common problem anyone using exec encounters: it hangs. The thing is, however, I do drain the input and error streams immediately, but it still hangs, and here's a curious thing:
    When I use a BufferedReader and use its readLine() method, it only manages to read the first two lines before it hangs, giving me an output such as this:
    +Microsoft Windows XP [Version 5.1.2600]+
    +(C) Copyright 1985-2001 Microsoft Corp.+
    Of course I placed the System.out.println inside the loop that reads lines, cause if I put it outside the loop, I don't get any output at all because the subprocess hangs before the loop is finished.
    Now if I don't use a buffer, and use the input's stream's read() method, it reads all the way through the output, but hangs at the end where it's supposed to read -1, and never reads it.
    I thought maybe I could bypass that, and break the loop at the last character in the output (the character '>'). Now while this works the first time, sending the output to the client like this:
    +Microsoft Windows XP [Version 5.1.2600]+
    +(C) Copyright 1985-2001 Microsoft Corp.+
    F:\eclipse workspace\RemCommand>
    However it doesn't work after that, when I try to type any command. I send my command to the subprocess normally using a PrintWriter, and then try to read the output, but that fails because apparently the subprocess is still stuck at the -1 from the previous read operation.
    I really don't know what the problem is, is it possible that the read possibly doesn't return -1 at all, maybe returns a different character to signify the end or something, and my loop keeps trying to read or what?
    I'm at my wits end.
    Any help?
    Thanks in advance.

    Here is the code again. Check the somehow improved detection of the default Windows prompt.
    Check the lines in comments that allow you to define your own, perhaps more reliable prompt.
    import java.io.*;
    import java.util.*;
    public class Cmd
      public static void main( String[] args ) throws Exception
        ProcessBuilder pb = new ProcessBuilder( "cmd" );
    //    Map<String, String> env = pb.environment();
    //    env.put( "PROMPT", ".,.,." );
        pb.redirectErrorStream( true );
        Process p = pb.start();
        InputStream is = p.getInputStream();
        OutputStream os = p.getOutputStream();
        PrintWriter pw = new PrintWriter( os, true );
        readToPrompt( is );
        pw.println( "dir" );
        readToPrompt( is );
        pw.println( "ipconfig" );
        readToPrompt( is );
        pw.println( "netstat" );
        readToPrompt( is );
      private static void readToPrompt( InputStream is ) throws IOException
        String s = "";
        for (;;)
          int i = is.read();
          if ( i < 0 )
            System.out.println();
            System.out.println( "EOF" );
            System.exit( 0 );
          s += new String( new byte[] { ( byte )i } ).charAt( 0 );
          if ( s.endsWith( "\r\n" ) )
            System.out.print( s );
            s = "";
    //      if ( s.equals( ".,.,." ) )
          if ( s.length() > 2 && s.charAt( 0 ) >= 'A' && s.charAt( 0 ) <= 'Z' && s.charAt( 1 ) == ':' && s.endsWith( ">" ) )
            System.out.print( s );
            break;
    }Edited by: baftos on Sep 10, 2008 11:27 AM

  • Problems running program using Runtime.exec()

    Hello everyone. I have a quick problem that perhaps someone can help me with... I'm trying to write a frontend for a command line program. I've found plenty of examples for using exec() to launch this program but I can't quite get the effect that I desire. The program itself launches it's own window (using a graphics library called SDL) but the user interacts with the program through the command prompt.
    The problem that I'm having is that my InputStream thread does not seem to execute until I close the SDL window. I've tried about 10 different combinations of threading this application but nothing seems to work.
    Below I've attached some sample code that I found here on the Sun site... The code does as I described before, the InputStream does not display any text until I close the SDL window.
    Can anyone help out?
    import java.io.*;
    // class StreamGobbler omitted for brevity
    class StreamGobbler extends Thread
    InputStream is;
    String type;
    OutputStream os;
    StreamGobbler(InputStream is, String type)
    this(is, type, null);
    StreamGobbler(InputStream is, String type, OutputStream redirect)
    this.is = is;
    this.type = type;
    this.os = redirect;
    public void run()
    try
    PrintWriter pw = null;
    if (os != null)
    pw = new PrintWriter(os);
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    while ( (line = br.readLine()) != null)
    if (pw != null)
    pw.println(line);
    System.out.println(type + ">" + line);
    if (pw != null)
    pw.flush();
    } catch (IOException ioe)
    ioe.printStackTrace();
    public class TestExec
    public static void main(String args[])
    if (args.length < 1)
    System.out.println("USAGE: java TestExec \"cmd\"");
    System.exit(1);
    try
    String cmd = args[0];
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd);
    // any error message?
    StreamGobbler errorGobbler = new
    StreamGobbler(proc.getErrorStream(), "ERR");
    // any output?
    StreamGobbler outputGobbler = new
    StreamGobbler(proc.getInputStream(), "OUT");
    // kick them off
    errorGobbler.start();
    outputGobbler.start();
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    } catch (Throwable t)
    t.printStackTrace();

    I'm pretty sure, because if you run the application without any parameters you don't get the SDL window, you just get a list of possible command line switches, that part works fine... It just seems that when the SDL window is open, the thread won't grab and display the individual lines until that window is closed, which will not work for my purposes...

  • Runtime.exec() makes program act weird

    Hello
    I have a problem with the runtime.exec() command?
    I have created a program in vb.net with a tcpClient that opens a stream to a server.
    When i execute the program myself it works fine, but when i run it through my java applet with runtime.exec() its suddenly hangs reading the stream?
    I can't make it work, and its so weird that the program reads the stream several times and then just hangs, even though i can see in wireshark that packets are recieved.
    Please help anyone who might know how to solve this :)

    Read and implement the recommendations in all sections of [When Runtime.exec() won't|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html].
    db

  • Runtime.exec() - how to open new window for new program?

    Hi,
    I have searched through the forums but haven't found an answer to this one yet. I am using runtime.exec() to start up a new java program. At first I thought it wasn't running properly but, after checking task manager, I have discovered that the new program I open runs, it is just completely invisible to me. I am wondering how I can get the new program to run in a command window or something where I can monitor it.
    Thank you for your help,
    Drew

    Thank you all. After trying to figure out why the start command wouldn't work in the runtime.exec() call(not an executable - I am a dolt), I tried putting it in a batch file and it worked perfectly. Thanks for your help,
    Drew

  • Runtime exec problem to execute a C program

    Hi,
    I've spend lot of time trying to find a solution without success...
    My aim is to run a C program from a java application under linux. My C code is the following:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    main(int argc, char **argv){
    printf("hello world \n");
    Once compiled I run my java application wich run the binary through a runtime.exec().
    I followed the example given by
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    with the same input gobblers and threads.
    For some reason it doesn't work: nothing comes out...
    When I call "ls" instead of my binary it works perfectly!
    WHY??
    Any help would be greatly appreciated!

    Thanks for the reply.
    Yes it seems that JNI could be a solution, but it looks a bit complicated an maybe not so well adapted to my purpose.
    The executables I want to execute from my java application don't need any arguments.
    If JNI is really the only way I'll try to use it but is there any good reason why runtime exec doesn't work? It is supposed to execute any executable isn't it?
    cheers

  • Runtime.exec() hangs on solaris 10, deadlock in soft_delete_session ?

    Hi,
    In my application sometimes Runtime.exec calls hangs for ever.
    The pstack of java process is at the end of the post. It seems like there is a deadlock in soft_delete_session.
    Does anyone know of any java/os patch we can apply to fix this issue?
    I will really appreciate any tips to get over this issue.
    # uname -a
    SunOS thor256 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-V245
    # /opt/VRTSjre/jre1.5/bin/java -version
    java version "1.5.0_10"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
    Java HotSpot(TM) Server VM (build 1.5.0_10-b03, mixed mode)
    The trace is as follows:
    0xff340408 __lwp_park + 0x10
    0xff339068 mutex_lock_internal + 0x5d0
    0xfb08a2ec soft_delete_session + 0xf0
    0xfb089f90 soft_delete_all_sessions + 0x4c
    0xfb084348 finalize_common + 0x70
    0xfb0844d8 softtoken_fini + 0x44
    0xfb0d8d48 _fini + 0x4
    0xff3c00d0 call_fini + 0xc8
    0xff3ca614 remove_hdl + 0xab8
    0xff3c4d54 dlclose_intn + 0x98
    0xff3c4e68 dlclose + 0x5c
    0xfb3a2b3c pkcs11_slottable_delete + 0x138
    0xfb39d664 pkcs11_fini + 0x4c
    0xff2c0ea0 postforkchild_handler + 0x30
    0xff332c20 fork + 0x140
    0xfe8f8df4 Java_java_lang_UNIXProcess_forkAndExec + 0x7d4
    0xf9226020 0xf9226020 * java.lang.UNIXProcess.forkAndExec(byte[], byte[], int, byte[], int, byte[], boolean, java.io.FileDescriptor, java.io.FileDescriptor, java.io.FileDescriptor) bci:0 (Compiled frame; information may be imprecise)
    0xf92216c4 0xf92216c4 * java.lang.UNIXProcess.(byte[], byte[], int, byte[], int, byte[], boolean) bci:62 line:53 (Compiled frame)
    0xf90fa6b8 0xf90fa6b8 * java.lang.ProcessImpl.start(java.lang.String[], java.util.Map, java.lang.String, boolean) bci:182 line:65 (Compiled frame)
    0xf90fbe0c 0xf90fbe0c * java.lang.ProcessBuilder.start() bci:112 line:451 (Compiled frame)
    0xf921842c 0xf921842c * java.lang.Runtime.exec(java.lang.String[], java.lang.String[], java.io.File) bci:16 line:591 (Compiled frame)
    0xf9005874 * java.lang.Runtime.exec(java.lang.String[]) bci:4 line:464 (Interpreted frame)
    0xf9005874 * TestExec.run() bci:26 line:22 (Interpreted frame)
    0xf9005c2c * java.lang.Thread.run() bci:11 line:595 (Interpreted frame)
    0xf9000218
    0xfecdca88 void JavaCalls::call_helper(JavaValue*,methodHandle*,JavaCallArguments*,Thread*) + 0x5b8
    0xfecf4310 void JavaCalls::call_virtual(JavaValue*,Handle,KlassHandle,symbolHandle,symbolHandle ,Thread*) + 0x18c
    0xfecf416c void thread_entry(JavaThread*,Thread*) + 0x12c
    0xfecf3ff0 void JavaThread::run() + 0x1f4
    0xff02fb30 void*_start(void*) + 0x200
    0xff340368 lwpstart

    Found this information about this problem:
    Bug: http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6276483
    Info for patch 127111-11: http://sunsolve.sun.com/search/document.do?assetkey=1-21-127111-11-1
    Download page: http://sunsolve.sun.com/show.do?target=patches/zos-s10

  • Problem with runtime.exec().It hangs Up

    Hi all,
    I am having a problem with the runtime.exec method.I am trying to execute linux commands using this method.For most of the commands it works fine.But when i tried to change the user with the su command in linux my program hung up.So please help me to get around this.any help would be highly appreciable..
    I am pasting the code..
    <code>
    Process p=null;
    int ch=0;
    try
    System.out.println("Before executing command");
    String unlock_command="sh changeuser.sh";
    p = Runtime.getRuntime().exec(new String[] {"/bin/sh","-c","su tony"});
    InputStreamReader myIStreamReader = new InputStreamReader(p.getInputStream());
    while ((ch = myIStreamReader.read()) != -1)
    System.out.print((char)ch);
    p.waitFor();
    int p_exitvalue = p.exitValue();
    System.out.println("After executing the command and the exit value = "+p_exitvalue);
    p.destroy();
    catch (IOException anIOException)
    System.out.println(anIOException);
    catch(Exception e)
    e.printStackTrace();
    </code>
    Thanks
    HowRYou

    Hi sabre,
    What you have pointed out is right.But if i change the user as root then it will not ask for a password.Isn't it.Anyway thank you for giving your suggestions.Can yoiu help me more.Waiting for all of your help.I will try to swoitch between different users othere than root by giving the password.So just help me.

Maybe you are looking for

  • DV6917CL won't detect HD

    Suddenly will not recognize the HD. The HD appears to be fine as I removed it and set up as an external drive and was able to read everything. Ideas? Thanks

  • How to upload into import archive

    How to import the XSL mapping and JCO LOOK UPS int to import archive archive  should i import java file or class file in look ups part , what abt the XSLT mappimg part, then i want to test the mapping part will you please tell me how to copy the alre

  • Inherit Primary - Service Requests & Activities

    Hi All, I have an issue with the Inherit Primary functionality with Books of Business. I have set this up between Service Requests and Activities. If I search for Activity records as I expect, I see all Activity records in my Book only, whether they

  • Navigator in Photoshop Not Working!

    Hi guys, my question is about my Navigator feature in Photoshop.  I use this feature all the time but yesterday it stopped working, saying my workspace had too many panels open to show Navigator, which was not true as all I really use is Layers, Hist

  • Rename files and retain portions of the original filename

    I posted a thread about this a while ago, but no solution was given: http://discussions.info.apple.com/thread.jspa?threadID=2564646 The issue is this: I can't figure out how to rename imported files while also retaining part of the original filename.