1

I have a Java program that requires our API's MiddleWare to be started first in order for it to work. The MiddleWare is contained in a Java Jar file.

Normally I have everything working if I open two separate command prompts and start the jar file first then run the java program second.

I'm packing up the new program for our clients now and I would like to find a way to automatically start the MiddleWare prior to starting the application. I tried something like this,

    @echo off
    set APP_HOME=C:\Temp\Hammer
    rem Set APP_HOME to the place where you installed Hammer.

    if "%~1"=="" (
       echo You must provide a Python script to run.
       pause
    ) else (
       java.exe -jar C:\GMSEC_API\bin\bolt.jar
       java.exe -cp  "%APP_HOME%\lib\jython.jar;%APP_HOME%\lib\Hammer.jar;%APP_HOME%\lib\gmsecapi.jar;%APP_HOME%\examples\Python;%APP_HOME%\jython2.5.3\Lib;%CLASSPATH%" bridenstine.hammer.main.Main %*
    )

But because the first java.exe command starts the MiddleWare first and it runs on a loop until terminated the second java.exe command doesn't get run until I ctr^c the first command.

So how could I start both commands in a synchronous fashion using one CMD file?

1 Answer 1

1

Try using start:

start java.exe -jar C:\GMSEC_API\bin\bolt.jar
start java.exe -cp  "%APP_HOME%\lib\jython.jar;%APP_HOME%\lib\Hammer.jar;%APP_HOME%\lib\gmsecapi.jar;%APP_HOME%\examples\Python;%APP_HOME%\jython2.5.3\Lib;%CLASSPATH%" bridenstine.hammer.main.Main %*

If you want the window to stay opened use:

start cmd /k java.exe -jar C:\GMSEC_API\bin\bolt.jar
start cmd /k java.exe -cp  "%APP_HOME%\lib\jython.jar;%APP_HOME%\lib\Hammer.jar;%APP_HOME%\lib\gmsecapi.jar;%APP_HOME%\examples\Python;%APP_HOME%\jython2.5.3\Lib;%CLASSPATH%" bridenstine.hammer.main.Main %*
1
  • That worked. Is there something I can add to keep the windows from shutting down after the program is done executing? Jul 21, 2014 at 0:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .