Running Java from a Windows batch file causes the batch file to stop

Posted by jjkparker on Super User See other posts from Super User or by jjkparker
Published on 2011-02-10T22:47:27Z Indexed on 2011/02/10 23:27 UTC
Read the original article Hit count: 556

Filed under:

When I run Java from a Windows .cmd file (Vista 32-bit here), the Java command causes the batch file to stop executing additional commands.

For example, this is a simple test.cmd file:

java
java

This should cause Java to print its help message twice. However when I run it in cmd.exe, I get this:

C:\>test

C:\>java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

where options include:
    -client       to select the "client" VM
    -server       to select the "server" VM
...

C:\>

The batch file simply exits when Java exits. What's going on here?

© Super User or respective owner

Related posts about batch