Runtime.exec() opening dos window.

I heard that in newer version of java (>java 1.2 ) if Runtime.exec() is used to execute some native program, a black dos promt is popped up automatically and closed when the execution of the native program is completed.
Will this happen every time I use Runtime.eceX()? is there a way to avoid this opening of dos prompt.

It will vary by os version. Read up on the use of the command or cmd statements from the os help information, and on the os's start command (may not exist in all os's)
Experiment fron the commandline to see what happens.

Similar Messages

  • Runtime exec opens new window

    Hi, I am using Runtime.exec to run an external application in Windows2000. � can read its output and i can destroy it without any problems.
    But when i run my java application with javaw , the external application i run with rt.exec opens new window(without output texts, empty) . just output command windows which opens when i run the external app. from a command prompt.
    If i run my java application with java.exe then then external application DO NOT open new window and run correctly. But this time my java window stays on desktop, and that's not any good for a Windows Application.
    In both cases everything runs OK. The only problem is the command prompt windows.
    Is there a solution when working with javaw.exe ? or hide the window when running with java.exe
    Thanks all.

    bug with ID: 4244515

  • Runtime.exec opening dos shell

    I am using runtime.exec() to execute the net use command (to get connected two machines). It is working fine, but exec() opening a new dos command window till it finishes its job.
    Is there any way to avoid this opening a dos shell and get the job done.I don't mind even If I can minimize this window instead of closing it.

    This is one of those common questions that keeps occuring.
    Basically it's a Windows/DOS problem not Java.
    Have a look at the "start" command in Windows.
    runtime.exec ("start /MIN mycommand.bat")
    will minimise your command window on execution.
    There's also a more promising /b parameter
    runtime.exec ("start /B mycommand.bat")
    which claims to avoid creating a window.
    However, if you're kicking off a native Windows program that explicitly
    creates it's windows then you should probably also look at it's parameters to see if there's a quiet/silent/batch mode which avoids creating the Windows.

  • Runtime.exec opens up new Window

    Hi, I am using Runtime.exec to run an external application in Windows2000. � can read its output and i can destroy it without any problems.
    But when i run my java application with javaw , the external application i run with rt.exec opens new window(without output texts, empty) . just output command windows which opens when i run the external app. from a command prompt.
    If i run my java application with java.exe then then external application DO NOT open new window and run correctly. But this time my java window stays on desktop, and that's not any good for a Windows Application.
    In both cases everything runs OK. The only problem is the command prompt windows.
    Is there a solution when working with javaw.exe ? or hide the window when running with java.exe
    Thanks all.

    When you use javaw, then the dos window that pops up is no longer needed, and you can close it manually and the java program will still run.
    To avoid this dos window, make a bat file to start your application. I guess you already do that, but make it this way
    start javaw ....
    exitI'm not sure if exit is necessary but I included it just to make sure it works.

  • Call x.exe and write command in opened DOS window

    Hi,
    I am using Labview 10 and Window 7. Just wondering how to use labview to
    1. run x.exe under opened DOS window?
    2. write command in opened DOS window?
    Any commends welcome,
    Thanks,
    Ott

    Please take a look here
    Alejandro | Academic Program Engineer | National Instruments

  • Runtime.exec open new DOS Window

    Hi,
    I want to execute a program (a.exe) having as work directory (C:\geo\B\)
    I create a batch file for changing into the directory and executing the command in the way:
    cd C:\geo\B
    start a.exeThis batch file (art.bat), I execute it in the following way within the run method of a Thread:
      public void run() {
          Process proc = Runtime.getRuntime().exec("cmd /K start " + art.bat);
          proc.waitFor();
          proc.destroy();
       }The fact is that works fine, but with this execution it opens a DOS window and i would prefer to avoid the appearance of new windows.... any help??
    Thanks All,
    Al

    cmd always opens a dos window - use another console interpreter instead or just call the programm directly.
    i.e.
    Runetime.exec("c:\\myprogram.exe");

  • 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

  • Runtime.exec error in windows

    When i try to run an external program with Runtime.exec() in windows 2000, i get a windows pop-up with the following error msg:
    d:\winnt\system32\ntvdm.exe
    Error while setting up environment for the application.
    I have no idea how to fix this since i have no clue to what that error means.
    Thanks
    Rumy

    I've personally just encountered the same error. I am building a piece of demonstration software to distribute with my graduate school applications to demonstrate my programming experience and I wish to include a set of programs I wrote some years ago in Pascal and C++. The software has been compiled for MS-DOS 6.0. I am using the following command to execute the software from within my Java program:
    Runtime.getRuntime().exec(new String[]{"command.com","/c","12cards.bat"});The batch file performs the appropriate setup operations for the program and runs the executable. When I run this code segment, I receive the following error:
    [16 bit MS-DOS Subsystem]
    C:\WINNT\system32\ntvdm.exe
    Error while setting up environment for the application. Choose 'Close' to terminate the application.
    I have another code segment in which I attempt to run the executable myself (without the help of command.com or the batch file). The code segment is as follows:
    Runtime.getRuntime().exec(new String[]{"12cards.exe"}, new String[0], workingDir);When I run this code segment, the following IOException is thrown:
    java.io.IOException: CreateProcess: 12CARDS.EXE error=2
         at java.lang.Win32Process.create(Native Method)
         at java.lang.Win32Process.<init>(Win32Process.java:66)
         at java.lang.Runtime.execInternal(Native Method)
         at java.lang.Runtime.exec(Runtime.java:566)
         at (my code)I have already found the document on Microsoft's support website which describes a solution to this problem. Manually extracting the autoexec.nt, config.nt, and command.com files from the installation CD-ROM did not help.
    The most confusing element of this: 12CARDS.EXE runs fine if I execute it from Windows Explorer. It's only a problem if it's executed from within my Java program. I have two other DOS programs which I want to include as well; I am having the same trouble with them.
    Any advice will be much appreciated. Thanks!

  • 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.

  • Runtime.exec and locked window

    So I'm working in a Swing application guaranteed to run only on Windows systems using Java 1.6 u 7. The users want a help button to launch a local web browser and point to the company's web site.
    After reading online and finding that getDesktop.browse() sometimes crashes in that version of Java, I use Runtime.exec("rundll ...") to kick off the local browser with the appropriate web address.
    The browser comes up appropriately, but the original Swing application's mouse pointer converts to an hourglass; I can click on the original window and get results but I can't open a new window.
    So I create a short thread implementing the Runnable interface and put the Runtime.exec call in that thread; I assume the problem is that the process is interfering with the GUI thread, and putting the Runtime.exec call in a separate thread will clear the problem up. It doesn't work; I still have the hourglass.
    I read online that some processes require that their input and error streams be consumed, or they may block; That shouldn't be a problem with internet explorer, but I add two threads to consume those streams; still no change.
    I also tried getDesktop().browse() anyway, and in a separate thread, and had the same problem.
    Does anyone have any suggestions?
    Respectfully,
    Brian P.

    Okay.
    First, let's look at the basic client.
    As you can see, when asked to show a window,
    it puts it in a separate thread for rendering:
    public class Client     
    // Show one example method
         private void showNewWindow(Window window)
              ourLogger.info("New request to display window: " + window.getClass().getName());
              if (window instanceof ClientWindow)
                   try
                        ((ClientWindow) window).bindFrames();
                        ((ClientWindow) window).setClient(this);
                        if (window instanceof ClientJDialog)
                             window = new ClientJDialog((ClientJDialog) window);
                        else
                             correctSize(window);
                        showCenter(window);
                        synchronized(myWindows)
                             myWindows.add(window);
                        counter = 0;
                        thread.hide();
                   catch (Exception re)
                        ourLogger.error("Client error while trying to show window", re);
                        ((ClientWindow) window).unbindFrames(false);
              else
                   throw new Error(window.getClass().getName() + " is NOT an instance of ClientWindow");
    // Snip some more
    At this same level on this class, I had originally put a showHelp() procedure with a single
    command thus:
         public void showHelp()
              Desktop.getDesktop().browse(java.net.URI.create(<help web site>));
    Simple, eh? But that gave me the hourglass as discussed. So I pushed it into a new thread.
    It eventually mutated thus:
         public void showHelp()
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
              //windows only
              Runtime rt = Runtime.getRuntime();
              Process p = rt.exec("rundll32 url.dll,FileProtocolHandler " + "<help URL>");
              StreamGobbler s1 = new StreamGobbler ("stdin", p.getInputStream ());
              StreamGobbler s2 = new StreamGobbler ("stderr", p.getErrorStream ());
              s1.start ();
              s2.start ();
              try {
              p.waitFor();
              } catch (java.lang.InterruptedException e) {}
    So as you can see, I ditched Desktop from Runtime and added a pair of stream consumers
    to ensure I wasn't having the stream problem our second poster discussed. Still no joy.
    I eventually replaced the url call with an attempt to invoke a simple batch file which
    did nothing, and I still had the same problem. I still have an hour glass, even when
    the process has been pushed into a new thread as you can see.
    Respectfully,
    Brian P.
    Edited by: pendell on Apr 16, 2010 3:14 PM

  • Is it possible to write to an open DOS windows - command line

    HI,
    I am able to open applications from LabVIEW, But except for the first command I am unable to write to the same application again and the LabVIEW will always open a new application. Is there a way to communicate with a DOS window application without re opening it each time? Is there a possibility to have a Dialogue with a DOS window?
    Thanks

    Hi,
    The command "Tasklist" will return the applications running in the system (as viewed in the task manager).  Parse the list and if the application you are trying to launch is already running do not launch else launch the application following the same procedure.
    With regards,
    JK
    (Certified LabVIEW Developer)
    Give Kudos for Good Answers, and Mark it a solution if your problem is solved.

  • Runtime.exec and dialog windows

    I'm using Runtime.exec to launch an exe that may crash due to runtime errors (such as division by zero). When this appens a dialog window shows up, waiting for the user to close it. (I'm running the program under Win98). Is there a way to avoid this?

    I think the only way should be fixing the exe bug!
    There is no way, I suppose.
    Ciao!

  • Runtime.exec work in windows but not in solaris??

    hi all,
    can someone tell me why the following code work in windows platform but doesnt work in solaris?The program tries to ping 127.0.0.1 and the output is correct in windows, but when i try it in solaris, it produces the following exception :
    Internal error: Unexpected Java exception thrown ( unknown exception, no description ) , stack:java.lang.NoClassDefFoundError: StreamGobbler
    at java.lang.Class.getDeclaredConstructors()(Native Method) ....
    The code is as follow:
    import java.util.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    class StreamGobbler extends Thread
         InputStream is=null;
         String type=null;
         PrintWriter out=null;
         StreamGobbler(InputStream is,String type,PrintWriter out)
         this.is=is;
         this.type=type;
         this.out=out;
         public void run()
              try
              InputStreamReader isr=new InputStreamReader(is);
              BufferedReader br=new BufferedReader(isr);
              System.out.println("finishing inputstreamReader and BufferedReader");
              String line=null;
              while (     (line=br.readLine())!=null )
                   {     out.println(type+"> "+line);
                        out.println("<br>");          
              catch (IOException ioe)
              {     ioe.printStackTrace();
    public class ping extends HttpServlet
         public void init(ServletConfig config) throws ServletException
         {     super.init();
         public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
              res.setContentType("text/html");
              PrintWriter out=res.getWriter();
         try     {
              Runtime rt=Runtime.getRuntime();
              System.out.println("pinging 127.0.0.1");
              String[] cmd={"ping","127.0.0.1"};
              Process proc=rt.exec(cmd);
              System.out.println("finishing process proc=rt.exec(cmd)");
              StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(),"ERROR",out);
              StreamGobbler outputGobbler= new StreamGobbler(proc.getInputStream(),"OUTPUT",out);
              errorGobbler.start();
              outputGobbler.start();
              int exitVal=proc.waitFor();
              out.println("Process exitValue: "+exitVal);
              out.close();
         catch (Throwable t)
                   t.printStackTrace();

    Did you copy all the class files to your solaris machine ? SOunds like you didn't copy all your files correctly.

  • Opening a new browser using Runtime.getRuntime().exec(cmd); under windows

    Can Runtime.getRuntime().exec(cmd); open a URL in to a new browser in wondows OS or ...can we force it to any specific browser insted on OS's default browser...
    It does open a new bowser under MAC but not under windows..
    cmd = "'rundll32 url.dll,FileProtocolHandler"+URL (windows)
    Thanks

    public class WindowsProcess
         public static void main(String[] args)
              throws Exception
              String[] cmd = new String[3];
              cmd[0] = "cmd.exe";
              cmd[1] = "/C";
              cmd[2] = "start";
              Process process = Runtime.getRuntime().exec( cmd );
              process = Runtime.getRuntime().exec( cmd );
    }When you run the above code you should get two open dos windows.
    Now just just enter some html filename and hit enter in each window. IE should start up separately in each window.
    Thats also what should happen if you specify the html file as the fourth parameter. A new process should be created and two separate windows should open with a browser in each.

  • 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

Maybe you are looking for

  • ITunes can't see my music

    This is probably covered somewhere else in this forum, but I couldn't find my particular problem after searching several posts I tried solutions given for similar problems, but they haven't solved mine. Like many users, I tried to move my itunes fold

  • AS3 project development into Flashbuilder

    I have been using Flex3 for mxml flex RIA development and I do pure AS3 development with Flash CS3 resources, which in most cases I code in Flex Builder but test and compile in Flash AS3. Twisted I know but the reasons are simple: 1. I can't access t

  • Failed to add action from OBIEE to Hyperion FR in 11.1.1.5

    Hi!, I tyed to link to FR reports by action link following the article [http://www.rittmanmead.com/2010/09/oracle-bi-ee-11g-integration-with-epm-11-1-2-hfr-action-framework/] Initially I configured ActionFrameworkConfig.xml next the credential map ke

  • Syncing folders with automator

    Hello, I would like to sync two folder and tried it with that http://www.apple.com/downloads/macosx/automator/syncfolders.html This works fine, but I need that the contents of these two folders is checked regarding certain file extensions and then sy

  • Confirmation Control key not allowed in MM Scheduling Agreement item.

    Hi Experts ,   I am facing an issue with Confirmation control key in MM Scheduling Agreement. Scheduling agreement already GRd without Conf-key and Now if am going to update confirmation control key as 0001. I am getting an error "Confrmation Control