7

I have to do a demo of an application, the application has a server.jar and client.jar. Both have command line arguments and are executable. I need to launch two instances of server.jar and two instances of client.jar.

I thought that using a batch file was the way to go, but, the batch file executes the first command (i.e. >server.bat [argument1] [argument2]) and does not do anything else unless I close the first instance, in which case it then runs the 2nd command. And also the I do not want a blank console window to open (or be minimized)

What I really need is a batch script that will just launch these apps without any console windows and launch all instances that I need.

Thanks in Advance!

EDIT:

javaw:

works if I type the command into the console window individually. If I put the same in the batch file, it will behave as before. Console window opens, one instance starts (whichever was first) and it does not proceed further unless I close the application in which case it runs the 2nd command. I want it to run all commands silently

PhoneixS
  • 10,574
  • 6
  • 57
  • 73
Virat Kadaru
  • 2,216
  • 4
  • 23
  • 28

3 Answers3

7

Found the solution, below is the contents of my batch file

@echo off

start /B server.jar [arg1] [arg2]  
start /B server.jar [arg3] [arg4]

start /B client.jar [arg5]
start /B client.jar [arg6]

@echo on

this opens, runs all the commands and closes the window, does not wait for the command to finish.

I am still not sure how to prevent the window from opening completely.

Virat Kadaru
  • 2,216
  • 4
  • 23
  • 28
  • If you don't want a console window, then don't use a batch file. Batch files are always started with `cmd` and thus you always end up with a console window. – Joey Apr 25 '11 at 08:25
  • @Joey it has little to do with cmd vs non cmd. Use `javaw.exe` instead of `java.exe` Python is similar `pyw.exe` vs `py.exe` Bonus: to minimize broken links between versions, use the "common" executable path. On my computer: `C:\Program Files (x86)\Common Files\Oracle\Java\javapath\javaw.exe` – Jon Grah Jul 25 '19 at 04:49
  • 1
    @JonGrah: The `cmd` window will appear when starting a batch file. This has nothing to do with what the batch file does. But indeed, for just launching a JAR without a console window, `javaw` has to be used as well (or a custom wrapper that uses the JRE as DLL). – Joey Jul 25 '19 at 14:09
6

Try:

javaw <args>
McDowell
  • 107,573
  • 31
  • 204
  • 267
  • works if I type the command into the console window individually. If the put the same in the batch file, it will behave as before. Console window opens, one instance starts (whichever was first) and it does not proceed further unless I close the application – Virat Kadaru Apr 02 '09 at 22:01
5

Alright after tring and cring, here goes my soluction

@echo off
start /B javaw -jar -Xms16m -Xmx512m client.jar
@echo on

I hope it will be usefull for somebody.