Eliminating the Command window in Windows

I had thought I had found a way to make the command window (the black command interpreter window in Windows that comes up when you run the JVM) go away. I used the following code:
public class StartApp {
     public static void main( String[] args ) {
          String command = "java";
          for ( int n = 0; n < args.length; n++ )
               command += " " + args[n];
          if ( args.length > 0 ) {
               try {
                    Runtime.getRuntime( ).exec( command );
                    System.exit( 0 );
               catch ( Exception e ) {
                    System.err.println( e );
                    System.exit( 1 );
          else
               System.out.println( "Format: java StartApp [-options] <filename> [arguments]" );
          System.exit( 0 );
When I run this Java app and put in another app for it to run, it runs that app just fine (it's a Swing app so I don't need the command window visible). Not only that, but it gives me the command line right after starting it (meaning the original app exited). So, theoretically, you would think I could just type "exit" to close the command window. Well, when I do type that, the command window waits until the program exits before actually closing. Manually closing the command window closes the whole program. The odd thing was, an older version (I think Java 1.1) of the JRE would allow the command window to close. But, with 1.3, it does not. Does anyone have any idea about how I could change this, or of another way to get rid of the command window?
-Sam Fahmie

Sorry, didn't put the code tag in right...
public class StartApp {
     public static void main( String[] args ) {
          String command = "java";
          for ( int n = 0; n < args.length; n++ )
               command += " " + args[n];
          if ( args.length > 0 ) {
               try {
                    Runtime.getRuntime( ).exec( command );
                    System.exit( 0 );
               catch ( Exception e ) {
                    System.err.println( e );
                    System.exit( 1 );
          else
               System.out.println( "Format: java StartApp [-options] <filename> [arguments]" );
          System.exit( 0 );

Similar Messages

  • How to get rid of the command window....

    How to get rid of the command window, automatically, once the .bat file which execute the .jar has been executed?
    Znx

    If you don't want the command window to show, use:
    javaw yourClass
    instead of...
    java yourClass

  • How do I keep the command window open?

    I want to write a batch file that will leave the window open after running so I can see what the output is.
    I kind of remember having to use %k
    But I'm not sure exactly how to do it.
    UPDATE: I found what I was looking for, it's /k when you execute the command file.
    If anyone has any additional comments about scripting and keeping the command window open, please comment.

    Add "pause" to the end of the batch.
    ¯\_(ツ)_/¯

  • To exit the command window after  weblogic app server startup

    Hi,
    The startWeblogic.cmd starts the weblogic V 10.0 server without exiting the prompt. Since our requirement wanted the startWeblogic script to exit the window after server startup, we set the parameter SET doExitFlag=true in startweblogic.cmd file , but the result was same as earlier the server started without exiting the window. Also we tried Redirecting the server starup output to a file , but even this did not exit the window.
    My query is
    1. What parameter options one should use to start the server so that it exits the command window in which it was started?
    2. Is there an alternate way to do the same,something like to start it as a background process in Windows?
    Any help in this regard would be great.
    Thanks in Advance.
    Best Regards,
    Preethi

    Not sure about parameters to startWeblogic.cmd, but from Windows you could
    try
    start /b startWebLogic.cmd > start.log 2 >& 1
    <Preethi Ghalke> wrote in message news:[email protected]..
    Hi,
    The startWeblogic.cmd starts the weblogic V 10.0 server without exiting the
    prompt. Since our requirement wanted the startWeblogic script to exit the
    window after server startup, we set the parameter SET doExitFlag=true in
    startweblogic.cmd file , but the result was same as earlier the server
    started without exiting the window. Also we tried Redirecting the server
    starup output to a file , but even this did not exit the window.
    My query is
    1. What parameter options one should use to start the server so that it
    exits the command window in which it was started?
    2. Is there an alternate way to do the same,something like to start it as a
    background process in Windows?
    Any help in this regard would be great.
    Thanks in Advance.
    Best Regards,
    Preethi

  • Changing the title of the Command Window

    How do i change the title of the command window form "C:\Programs\jdk1.2.1\bin..." etc to something more useful like "MyProgram"?
    Many thanks
    Cath

    What I amproposing is that if we all merge on the same chapter and examples then we can ask each other specific questions and all have the same benchmarrk and reference points!!
    I plan to advertize this on other lists and if we all use the same text then we are all the much further ahead instead of having questions from all sorts of text and nobody knowing what the other is doing and having completely different code and examples!!
    What do yu guys think?
    Personally, I am in chapter 8 just staring SWING. But I don't mind going back to the first part to help othere newbies (as long as we have the same text and the examples are from the text).
    For example, I have modified example 8-1, so that instead of just showing colors in the background, the buttons show a photo with text, shows text and changes the background, and will do something else ( don't know what yet)! But the whole thing is still based on the example code on page 323.
    I had some problems trying to figure how to do this... but if we all work on projects that are based on the code examples for the same text, we stand a better chance of all learning faster...
    So Yes, it is a study group using emails or chats...forum.
    The main difference is that if a person needs help we can all share code with them (NOT NECESSARILY DOING THE PROJECT...unless you wan to) but with the same book {Core Java2-Fundamentals or Core Java2- Advanced Programming} and with the help of at least one senior programmer that we have on the thread already ... with the otheres like you that want to join...all using the same book....Then no matter what project you are working on (from the book or work or school) we all have the same text to help each other and to reger each other to.
    Moreover, there never need to be another instance where the answer comes back: "read the tutorial" or check the docuemtation.... Those are good answers if you know what you are lloking for...but sometimes a person may need an example in working code.... and the tutorials don't answer specific questions where a person may not quite understand.
    So,
    why not stop by the New Study group that is going?...you can find us in forum New To Java Technology
    under the thread of "is anyone learning Java using the Sun Microsystems book...."
    In the meantime.... the person that was asking for hel here has not posted anything ... So I wonder if she realy wanted help?
    I will hang out here fopr another day or so and see if she answers my questions to her .. If nt then i will assume that this is a dead thread and I will no longer be here. You know where you can find me....
    phil

  • NOT displaying the command window when running applications

    hi
    i'v been seraching all over the web for a way to get rid of the command window (dos shell) that appears when running a java swing based application (or any other). i currently have a batch file that loads all the required libraries into the class path and then calls the application's main class. problem is, the DOS command window stays open. is there any way to have it not display (obviously without losing my program in the process). at the very least can it be minimised automatically (just the dos window)?? though i think getting rid of it all together would be best.
    i would really love some help on this... very over seeing that dos window displayed...
    any help would be greatly appreciated.... thanks heaps
    Takis

    On Win NT
    REM get rid of commnand window
    start /B java swingapp
    REM minimize the command window
    start /MIN java swingapp
    REM for other options
    help start
    Hope this helps,
    Sathish.
    hi
    i'v been seraching all over the web for a way to get rid of the command window (dos shell) that appears when running a java swing based application (or any other). i currently have a batch file that loads all the required libraries into the class path and then calls the application's main class. problem is, the DOS command window stays open. is there any way to have it not display (obviously without losing my program in the process). at the very least can it be minimised automatically (just the dos window)?? though i think getting rid of it all together would be best.
    i would really love some help on this... very over seeing that dos window displayed...
    any help would be greatly appreciated.... thanks heaps
    Takis

  • Run a jar on Windows without the command window

    I would like to run a jar and close the command window after starting up. Is this possible please.

    I would like to run a jar and close the command window after starting up. Is this possible please.why do you want to do that? jar files are executable files so when you double click it, it will execute without having to run it from the command prompt. So, you don't have to even open the cmd prompt to run .jar files.

  • Serveroutput in the command window of PLSQL Developer

    In sqlplus, I input the following SQL:
    SQL> set serveroutput on
    SQL> show serveroutput
    serveroutput ON SIZE UNLIMITED FORMAT WORD_WRAPPED
    SQL> select /*+ no_index(t1 idx_t1) */ * from t1 where n=3;
         N
         3
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    While I input the same SQL in PLSQL Developer:
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    SQL_ID     9babjv8yq8ru3, child number 0
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
    NOTE: cannot fetch plan for SQL_ID: 9babjv8yq8ru3, CHILD_NUMBER: 0
    Please verify value of SQL_ID and CHILD_NUMBER;
    It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    And the most important is:
    SQL> show serveroutput
    SQL>
    The result of it is empty.
    The reason for that is serveroutput is only supported in sqlplus not PLSQL? I know serveroutput is sqlplus language not SQL. However I use "show serveroutput" in command window of PLSQL Developer which is the same as sqlplus. What's the real reason for that?
    Thanks for your kindly reply.

    " If serveroutput is on when you call this function, the last statement you will have run will be the (hidden) call to dbms_output that follows your execution of any other statement – so you won’t get the plan and statistics."
    http://jonathanlewis.wordpress.com/2006/11/09/dbms_xplan-in-10g/
    "Luckily I recognized the line BEGIN DBMS_OUTPUT.GET_LINES(...); END; from the tkprof output files. It is what SQL*Plus does after each statement: flushing the dbms_output buffer to the screen. To have the dbms_xplan.display_cursor show what I want, I started writing a little script against V$SQL to get the latest "real" SQL-statement, but then I realised I cannot possibly be the first to encounter this problem. Googling led me to this very useful blog entry by Jonathan Lewis. It contains almost everything you want to know about the display_cursor function. A simple "set serveroutput off" is enough to get the function working! "
    http://rwijk.blogspot.nl/2008/03/dbmsxplandisplaycursor.html
    So, actually you should have set serverout off.
    Probably also depending on how you're gathering the execution plan statistics (you're not using the gather_plan_statistics hint?) and the SQL*Plus version and database version you're working with...

  • Labview code for closing the command window

    Hi,
    This is naveen.Actually we are using 3rd paty test software for our mobile hardware testing which creates an DOS or Command window after execution.We have automated to execute this software using labview.the problem we facing is that we couldn't run the test software unless we close or kill the dos window opened in the previous run.So i like to know whether you have any labview code for closing or killing the DOS window ,i request you help me in this regard.
    regards,
    Naveen 

    Use the System Exec VI Owning Palette: Libraries & Executables VIs and Functions.
    And take a look here http://www.tech-recipes.com/rx/446/xp_kill_windows_process_command_line_taskkill/
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Can the command window go away?

    We're upgrading from 6.0 to 6.1 and on our Windows development machines, the new version pops open a command window, which we can't seem to make go away.
    This didn't happen in 6.0, and they're kind of annoying. How can we get the 6.1 server to start without opening a command window?

    The easiest way to stop this is to go into the Services tool for Windows and uncheck the "Interact with desktop" option for the Web Server service. If this is on Win2k this is under the "LogOn" tab.
    --jb                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Supressing the Java command window ???

    Hi,
    How do I get rid of the command window from where I start my Java Application ?
    Even if there is a way what will happen to all the System.out.println() calls in my applicatio ?
    Thanks in advance.

    You can just not start the Java application from a command window or batch file. The easiest way to do this is to create an executable JAR file which a person (on Windows) can just double-click. Do a search on "executable JAR".

  • Again...Suppressing the Java Command Window

    Hi,
    My invoking my java application with "javaw", I'm able to suppress the command window.
    None of the System.out.println() is now seen. Thanks for that.
    But there is another problem that I see.
    In my application, I run some batchfiles using the Runtime.exec
    with the "cmd" parameter. This is making a separate command window
    pop up from no where.
    This pop up is happening for every call I make ? Can this be avoided at all ???
    Or should I live with it ??
    Many Thanks

    You may have to live with that cause cmd runs with its own window. I haven't used this very much but for the little I have done, I can't ever seem to get it to hide, unless you decide to use START to run the activity and then call EXIT in the batch file so it closes as soon as it is done.
    ICE

  • Minimizing the java command window?

    I'm running a excutable jar file:
    'java -jar myExe.jar'
    i leave the command window open, and task manager window open next to it. when i minimize my command window, i see the CPU usage for the java process go down. why does it do that?

    Nobody has experienced this before?

  • Command window stays opened at the end of script execution

    Hello everyone,
    Since I install Windows 2012 R2 systems, the command window opened when I execute my batch scripts often stay opened even if the script has ended.
    As an example if I double-click a batch file, if the last line of the script is "echo here", it displays "here" and the window is not closed by Windows (it's not active of course, it just stays opened).
    I found an easy way to trigger the (apparently) same problem. Do like this:
    - right click the Windows button at the bottom left. Select "Command prompt"
    - in the command window type "mstsc"
    - close mstsc clicking on the close button
    - type "exit" in the command window (or click the close button)
    Now the command prompt is "frozen". I cannot type any command in it and I have to click the close button a second time to close it.
    Anyone has an idea what is causing this? 
    Thanks

    Hi Anna,
    Sorry. I didn't receive any update notification email :-/
    I tried using "start" as you suggested by you and the article you gave. No change at all.
    To explain better I did a video you can see here : http://pferrucci.perso.sfr.fr/Issue/  (unfortunately I couldn't do it better).
    It shows :
    - I open a command prompt as Administrator (just to be sure, but it's the same as a non-admin user)
    - I run taskmgr and I close it when it opens
    - at this point, I type "exit" to close the console window. NOTE: at this moment you can see the window title changes from "Administrator : command prompt" to "command prompt". Maybe it is of interest.
    - from now on, I can't type anything at the prompt. It is just disabled.
    - I click on the close button once (see below)
    - I open a second command prompt as Administrator. I run taskmgr and I close it.
    - at this point, I click the close button once to close the console window. The button reacts but the window stays opened. At this point I could type some text at the prompt, the prompt would not react. It is just disabled.
    - I click on the close button a second time.  The Window goes away.

  • Workflow 2.6.4.0.0 configuration problem - Command window does not close

    I am trying to install Oracle Workflow 2.6.4.0.0. as part of Warehouse builder using the details mentioned in this link
    http://www.oracle.com/technology/obe/10gr2_owb/owb10gr2_gs/owb/lesson4/etl-mappings.htm
    From the Start menu click Programs > Oracle <Database HOME> > Configuration and Migration Tools >
    Workflow Configuration Assistant. The Assistant is started.
    Accept the default for Install Option
    Workflow Account: (Accept the default ) owf_mgr
    Workflow Password: owf_mgr
    SYS Password : <Enter the SYS account password>
    TNS Connect Descriptor: localhost:1521:orcl
    Click Submit.
    However following this document, the command window did not close, and I did not get any message stating that Workflow Configuration has successfully completed.
    The command window displays this message as the final step and does not close-
    WorkflowCA: Executing :C:\oracle\product\10.2.0\db_1\jdk\bin\java -jar C:\oracle
    \product\10.2.0\db_1\oc4j\j2ee\home\admin.jar ormi://localhost:6041 admin welcome -application WFALSNRSVCApp -testDataSource -location jdbc/WorkflowDS -username OWF_MGR
    Is this installation complete? How to resolve this?
    Please can any one help?
    Thanks very much
    Allan

    I ran into this problem. And it took me while to get it fixed, but It does work.
    First the TNS Desc is misleading. One would think that it would be host:port:sid. What it is really looking for is host:port:servicename. But if you want to use the "Change Tablespace" drop down list you need to, enter the sys password, change it to host:port:sid - Then use the drop list. And change it back before you press submit.
    The second thing that I found is that it wants to use the SYSTEM tablespace as temporary tablespace. THis is becuase it is looking for a temp tablespace called TEMP. If you look a the line default_temp = SYSTEM. And if you dont supply a tablespace it wanted to change it in the wfsysgnt.sql script in the $OH\wf\sql directory. You would think that what ever the default database tbs and temp tbs is - that owf would use that. No, it wanted to change it. Oracle needs to fix this.
    So here is how i fixed it. I had to create a temporary tablespace called TEMP, does not need to be big as I dropped it after it was done. Then i had to modify the wfinstall.csh script and use the install options. Not the /tablespace this option is obayed but it will try to use the SYSTEM as the temp tbs. Here is my example that I appended:
    /wfacct "owf_mgr" /wfpasswd "my_owf_mgr_pwd" /debug "true" /tnsConnDesc "my_host_ip:my_port:my_servicename" /syspasswd "change_on_install" /tablespace "OWF_TBS"

Maybe you are looking for