Runtime.exec - hidding the ugly black dos window

Hello,
Could someone tlle me how to hide the dos command which is always opened when using Runtime.exec on a windows OS?
I also know that there's already lots of questions already posted on this subject but I can't find them.. So links could help me....
Loic

Here's what came up when I searched the forum using "hide runtime":
http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=hide+runtime&x=10&y=10

Similar Messages

  • Runtime.exec ignores the working directory argument

    Hi Folks,
    I need to run a batch file in a particular directory, from a Java program.
    Here, I want to run "startMySQL.bat" from the ./bin directory.
    I used the following code to do so.
         String commandToExecute = "startMySQL.bat";
         File file = new File("bin");
    Process sqlPrcs = Runtime.getRuntime().exec(commandToExecute, null, file);     
    When I run these lines in a program, I get the following exception:
    java.io.IOException: CreateProcess: startMySQL.bat error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Unknown Source)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at com.aperto.ems.packetmax.AuthenticationScreen.startDB(AuthenticationScreen.java:603)
    at com.aperto.ems.packetmax.AuthenticationScreen.validateUserAndReinitialize(AuthenticationScreen.java:479)
    at com.aperto.ems.packetmax.AuthenticationScreen.access$0(AuthenticationScreen.java:468)
    at com.aperto.ems.packetmax.AuthenticationScreen$OnOKButtonPress.actionPerformed(AuthenticationScreen.java:628)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener$ReleasedAction.actionPerformed(Unknown Source)
    at javax.swing.SwingUtilities.notifyAction(Unknown Source)
    at javax.swing.JComponent.processKeyBinding(Unknown Source)
    at javax.swing.JComponent.processKeyBindings(Unknown Source)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    "error=2" in Windows mean "not able to find the file".
    Any clues on how I can run the batch file from a particular working directory?
    Thanks!

    Hi,
    I changed the code to print the user.dir output and the absolute path of the file. It looks like this:
    String commandToExecute = "startMySQL.bat";
    File fl = new File("bin");
    System.out.println(fl.getAbsolutePath());
    System.out.println(System.getProperty("user.dir"));
    Process sqlPrcs = Runtime.getRuntime().exec(commandToExecute, null, fl);
    Below is the output I get:
    C:\Program Files\Aperto\WaveCenter\Back-End_Server_2.0_build8\bin
    C:\Program Files\Aperto\WaveCenter\Back-End_Server_2.0_build8
    java.io.IOException: CreateProcess: startMySQL.bat error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Unknown Source)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at com.aperto.ems.packetmax.AuthenticationScreen.startDB(AuthenticationScreen.java:604)
    at com.aperto.ems.packetmax.AuthenticationScreen.validateUserAndReinitialize(AuthenticationScreen.java:479)
    at com.aperto.ems.packetmax.AuthenticationScreen.access$0(AuthenticationScreen.java:468)
    at com.aperto.ems.packetmax.AuthenticationScreen$OnOKButtonPress.actionPerformed(AuthenticationScreen.java:629)
    I assure you, "startMySQL.bat" is there under "bin"
    Thanks,
    Sandeep

  • FRM-10142 The Http Listener (Dos Window Does not Stay Open)

    Dear Sir
    URGENT
    When I start OC4J instance its dos window open for few seconds and after that its closed.
    I mean OC4J instance dos window des not staying open at task bar.In oracle 10g forms builder and 11g database
    Please guide me how this problem would be solve...?
    Yassen

    For URGENT questions go right to https://support.oracle.com and file a Prio 1 SR with Oracle Support. For everything else I don't see why your question is more urgent then others.
    Did you check if maybe the port OC4J runs on (8889) is already used by another program (netstat)? Did you check the logfiles?
    cheers

  • Runtime.exec() - Strips the parameter list on encountering  a newline(\n)

    I am executing a batch file from Runtime.exec() and i am passing a list of parameters to the batch file in the form of name=value pairs.One of the parameters value is a multiline text containing "\n" characters.i.e input from a textarea.
    When my program executes the batch file it prints all the parameters till it encounters the "\n" character and strips all the remianing parameters.And it does not show any error .
    Is this a bug of Runtime.exec method ?
    If not, how to resolve this problem?

    Bug in Runtime.exec? Nope, it's probably you and your code.
    Read this - everyone who uses Runtime.exec should:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Can I disable/hide the brush tilt animation window?

    Adobe instituted the dynamic brushes in CS5 and I'm fine with that. What I'm not fine with is not being able to hide that pop window that's supposed to aid you with knowing how the stylus is positioned in space. It's annoying. I want to hide it, or at least make it smaller. It takes takes up way too much space and I don't know if ANYONE spends their time looking at it while drawing. I do like the brush icon at the tip though and how it changes shape based on angle. Maybe this should be in feature request?

    If you hover the mouse/pen over the top of the window you can press the X to close the window or go to View>Show and uncheck Brush Preview.
    You can also move the window or click on the double arrow to make the window smaller.

  • Hide the Bluetooth File Transfer Window

    Can anyone give me any clues as to how I could stop the File transfer WIndow appearing when I Bluetooth an image from phone to my Mac?
    It is the Obex Agent window. That says Incoming File etc
    It will appear over any open applications right in the centre of the screen. I have tried instantly hiding it when it appears with Applescript but this is not quite good enough for my purposes.
    Any idea how I can ideally disable it. Or at least move its location.
    Or a better place to ask for help?
    Thanks
    Gavin

    Apple aren't here. You won't get a response from Apple on this user-to-user help forum.
    Although speculation on Apple policies is not permitted on this forum, it has been previously speculated frequently, that the reasons for not allowing Bluetooth file transfers are:
    1) Bluetooth is too slow for transferring multi-megabyte / gigabyte media files that iOS devices typically store. There are much faster ways of transferring files, not limited by arbitrary distances Bluetooth is.
    2) Allowing file transfers would allow illegal sharing of copyrighted music and video files. Apple has a duty to protect such files from easy sharing due to agreements with the copyright holders for whom they sell this copyrighted content in the iTunes Store.

  • Starting command line exec without dos window...

    I'm trying to start a console window application under my java swing application with the Runtime.exec(cmd) function.
    A dos window appear during the execution of the application. How to remove the screen echo ?
    Thanks
    SEB

    Hi ollie lord and thank you for your suggestion.
    I tried to use a *.bat file instead but the result was the same. I tried to use the word "start" in the command but nothing more.
    My .bat file is simple:
    start myprogram or myprogram
    ...where myprogram.exe is a win32 console application from Visual C++.
    Is there any option in function Main() in C++ to remove the dos console ?
    I head about the JNI tech. Is it a solution ?
    Thanks
    SEB

  • How do you prevent MS-DOS window from appearing during Runtime.exec()?

    The question below was attached to the answer for Question of the Week No. 21. I'm having the same problem. Does anyone know the answer? Put another way does anyone know how javaw does it?
    Fri Dec 18 09:59:52 PST 1998
    rkarasek
    On Windows NT 4.0, how can I prevent CreateProcess()
    from creating a cmd.exe window when using javaw and
    Runtime.exec()? No such cmd.exe window is created if
    instead I run "java" from the command line.
    I have a C++ server named "foo", and have created
    a Java applcation with Swing GUI named "foo.java".
    This GUI captures configuration information and
    then uses Runtime.exec() to start the C++ app, with
    a socket established between the Java app and C++
    app for later communication.
    This is all working fine, and the Java application
    and GUI working as expected. When I run "java foo"
    from either the NT command shell (cmd.exe) or MKS
    Korn shell (sh.exe) the Java application/GUI starts,
    and when it calls Runtime.exec() my C++ process is
    started as what appears to be a child process of the
    "java" process, that is, no cmd.exe window is created
    during the Runtime.exec("foo.exe") call.
    However, when running the same Java application from
    a shortcut on the desktop via "javaw", when I invoke
    Runtime.exec() a cmd.exe window is created before my
    C++ server is started. While things are running
    ok and my Java app can still communicate with my
    C++ server, is there anyway I can prevent this
    cmd.exe window from being created, and instead, have
    my C++ server run as a child process of javaw (or
    an independent process without a cmd.exe)?

    cmd always opens a dos window - use another console interpreter instead or just call the programm directly.
    i.e.
    Runetime.exec("c:\\myprogram.exe");
    OR
    The following demonstrates executing a command without bringing up a popup. import java.io.*;
    public class Test {
      public static void main (String args[]) throws IOException {
        String[] command = {
          "C:\\winnt\\system32\\cmd.exe", "/y", "/c",
          "dir"};
        Process p = Runtime.getRuntime().exec(command);
        InputStream is = p.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        while ((line = br.readLine()) != null) {
          System.out.println(line);
    }However....
    According to bug number 4244515 in Sun's Bug Parade (http://developer.java.sun.com/developer/bugParade/bugs/4244515.html), javaw doesn't always work without bringing up new window.

  • The Runtime.exec methods doesn't work well on Solaris ???

    I have two threads and I set the different running time.
    I use Runtime.exec to a run the command and use Process to get the process.
    It works properly in the windows2000 platform.
    However, when I transfer the platform to Solaris...and run the program...
    Two threads always at the same time....It is very wired....I always debug
    for 2 days....
    (at first I run "vmstat 1 2" command, later I change to "ls","rmdir"....etc,
    all of them don't work.....
    If I close the Runtime.exec..........Everything works well......)
    And I study the API. I found this message...
    The Runtime.exec methods may not work well for special processes on certain
    native platforms, such as native windowing processes, daemon processes,
    Win16/DOS processes on Win32, or shell scripts. The created subprocess does
    not have its own terminal or console.
    Could someone share her/his experience.....:(
    And if any other way I can run command inside java code instead of
    Runtime.exec.....???
    Please reply my mail to [email protected] I do appreciate your kindly &
    great help!!!!!!!!
    This is my code.......
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    * <p>ServerThread1</p>
    * <p>??�X???��?�D???�X???, "Vmstat 1 2".</p>
    class ServerThread1 extends Thread{
    private ServerAgent Sa;
    public ServerThread1 (String Name, ServerAgent Sa){
    super(Name);
    this.Sa = Sa; file://Assign ServerAgent reference Sa
    public void run(){
    while(true){
    try{
    Thread.sleep(5000);
    catch (Exception e){
    System.out.println("ServerThread1 fails");
    System.out.println("Thread1 is running.");
    try {
    Runtime rt1 = Runtime.getRuntime();
    Process proc1 = rt1.exec("mkdir"); ------>If I close
    rt1.exec , two threads works seperately...........:(
    catch (Exception e) {
    System.out.println("Thread1 Error");
    class ServerThread2 extends Thread{
    private ServerAgent Sa;
    public ServerThread2 (String Name, ServerAgent Sa){
    super(Name);
    this.Sa = Sa;
    public void run(){
    while(true){
    try{
    Thread.sleep(15000);
    catch (Exception e){
    System.out.println("ServerThread2 fails");
    System.out.println("Thread2 is running.");
    try {
    Runtime rt2 = Runtime.getRuntime();
    Process proc2 = rt2.exec("vmstat 1 2"); ----->If I don't run
    the rt2.exe, two threads work seperately....
    catch (Exception e) {
    System.out.println("Thread2 Error");
    public class ServerAgent{
    private Vector v1 = new Vector();
    private Vector v2 = new Vector();
    private Hashtable currentData = new Hashtable();
    private static String startUpSwap = null;
    private static String startUpMem = null;
    public static void main(String[] arg) {
    ServerAgent s = new ServerAgent();
    ServerThread1 st1 = new ServerThread1("Thread1",s);
    ServerThread2 st2 = new ServerThread2("Thread2",s);
    st1.start();
    st2.start();

    If I close the Runtime.exec..........Everything works
    well......)You don't empty the output of the command, that blocks the process.
    A citation from
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Why Runtime.exec() hangs
    The JDK's Javadoc documentation provides the answer to this question:
    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.
    Try out something like this:
    String s;
    try {
       Process myProcess =
       Runtime.getRuntime().exec("ls -l"));
       DataInputStream in = new DataInputStream(
              new BufferedInputStream(myProcess.getInputStream()));
        while ((s = in.readLine()) != null) {
            out.println(s);
    catch (IOException e) {
        out.println("Error: " + e);
    }Another source of trouble under Unix is not having the correct permission for that user that executes the Java VM, which will be the permissions for the spawned subprocess. But this probably not the case, as you see something after exit.
    Regards,
    Marc

  • Any way to close the DOS window ?

    Is there anyway to close the DOS window, after executing a DOS command in a GUI Java program ?
    I keep getting "Please press any key to continue..."..I don't think I can use the System.exit in a GUI Java program?

    Yes.
    Process p = Runtime.getRuntime().exec(...);
    PrintStream out = new PrintStream(p.getOutputStream(), true);
    out.print("a");You get the output stream of that process and print an a (which I guess will work just like you pressed a key). I don't know if there has to be a delay before you write this character. If you send it before it has written "Press a key ..", then it might not work. In this case you can add a line with Thread.sleep(1000); to sleep for 1 sec in this example, just before you execute the print statement. Or you can get the InputStream from the process, and read everything it sends and check if/when you get the "Press a key .." text:
    PrintStream out = new PrintStream(p.getOutputStream(), true);
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String s;
    while ((s = br.readLine()) != null) {
      if (s.startsWith("Press a key")) {
        break;
    out.print("a");something like that..
    There might be cases where you don't get a "Press a key" back if the DOS window is big enough to hold all the information (it is possible to change the buffer for DOS windows so they can hold more than 25 lines).

  • Runtime.exec() for different Windows versions ?

    Hello all.
    I'm currently developing a Java program that uses Runtime.exec() to launch a MS-DOS application (the old MS-Kermit). It works fine under Windows ME and Java 1.3.1 but the very same code fails to work under Windows 2000. That's very bad for me, since my program should work on all windows platforms from 95 up to XP (and NT).
    My question is : can I trust Runtime.exec() or am I damned to write different versions of the same command for different operating systems ?
    Thanks.

    Runtime is not os independent, so yes, it has to accomodate the os differences. There is an enhancement request on the subject, tho.
    Search the forums, there is code that handles the differences posted.

  • I can no longer edit bookmark names in the little black window since a recent update.

    A bookmark title can no longer be edited, or parts of it deleted, in the small black dialogue window that appears when creating a new bookmark. This has happened since a recent update July 2010 version 3.6.7 or 3.6.8

    I have the same problem. It occurred 2 or 3 upgrades ago. Before that I could easily change the name of a bookmark within the dialog box. I now have to delete it entirely and then write in what I want. Needless to tell all of you, it's annoying! I'm running an imac 24 inch with 10.64 and the latest firefox 3.6.11.
    Does anyone troll this site and tell the powers that be? Obviously we'd all like this fixed and it's not an isolated problem.

  • How to give path in Runtime. exec( )

    Hi,
    I am trying to create an user interface, in which, it should open a different file (for example, example.doc)when a button is clicked in the applet. let us say, the path for example.doc is "C:\\WINDOWS\\DeskTOP\\folder1".
    I tried with the following code
    Runtime.getRuntime().exec("C:\\WINDOWS\\Desktop\\folder1\\example.doc");
    but, when I click on the button it is not opening example file and I am getting an exception. I am using Runtime.exec() command for the first time.Anybody can help me with this???

    Since when was a document an executable? The main problem is many people think Runtime.exec () is the same thing as the command line. The answer is, it's not. Typing "example.doc" in the windows terminal emulator (also known as cmd.exe in Windows 2000/XP or command.com in others) will work because example.doc is opened with the application configured to open files with the ".doc" extension.
    However, files ending with ".doc" are not executables. If you wish to open a ".doc" file with the associated application, try this: Runtime.getRuntime ().exec ("cmd /c example.doc"); Not that I don't know if this will work with command.com as I haven't tried, but it should work with cmd.exe without problems.
    Hope it helps.
    Cheers

  • Ugly black background in Mission Control

    How can I change the ugly black background in Mission Control?  On my 27" screen it looks bad and reflects too much.

    Hi,
    My Normal Settings are.
    Left  gives me Dashboard.
    Right  is normally iTunes in Full Screen Mode.
    I run Messages with 8 or 9 individual Buddy Lists open as well as the Chat/Interface Main window.
    If I set  the main Messages window to Full Screen then it will do so but the Buddy lists remain on the "central" screen (Space?).
    The Main window has moved to the right.
    If  go to look at Messages and then use the Dock > Mission Control icon the Messages app is still on view.
    EDIT
    Or it was when I tested this first and made me wonder if this was what you meant by "background"
    I repeated this to take a snap shot  and can only get my Desktop as the Background whilst the Dashboard, Desktop space and Messages spaces show across the top.
    During the initial process I did change some things in the Messages > Preferences > Accounts.
    I had spotted two were not Logged in and I also changed the Descriptions for them.
    9:26 pm      Saturday; January 25, 2014
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Runtime.exec() does not work normally

    I try to wrapper the oracle connect command on unix using this function:
    runtime.exec("sqlplus username/password@dbinstance")
    it is ok on windows, but on unix, after runing the class, I get nothing. what is the problem?
    Please help me. thanks

    There are several traps with runtime.exec(). The most important one is that you should read
    the output stream of the launched program. Otherwise it will stop running when the console buffer overflows. The size of the buffer differs for various OSes.
    Look at this article:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    It it does not answer your problem, try to search the forums:
    http://search.java.sun.com/Search/java?qt=%2B%22exec%22+-%22Replies%3A+0%22&col=javafrm&rf=0&qp=%2Bforum%3A31
    This problem has been asked hundreds of times.
    Hope, this helps.

Maybe you are looking for