16

I wrote a batch file that runs a jar file. But after it runs the jar file the batch file doesn't close until the jar file is also closed. How can I close the command screen when it opens the jar file?( when the jar file is open I want to close the command screen.)

My batch file :

@echo off
java\jre7\bin\javaw.exe -jar ".\sample.jar"
exit
Daniella
  • 171
  • 2
  • 3
  • 14
CompEng
  • 7,161
  • 16
  • 68
  • 122

2 Answers2

23

Use the start command before the rest of the command.

MByD
  • 135,866
  • 28
  • 264
  • 277
11

I have recently had this problem and for someone other in future, complete and simple way is here:

@echo off
start javaw -jar "nameOfJar.jar"
exit

This starts jar and close CLI.

Important is the "start" command and the "javaw" command for windows environment.

Leo
  • 472
  • 5
  • 9
Androdos
  • 653
  • 8
  • 11