1

I can't believe this is difficult. But all the stuff I'm reading on Microsoft sites says to run the batch file minimized - which is ridiculous, or launch via VB script???? I have to run a VB script to launch a batch file??? This is insanity.

Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
  • http://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window – mre Jul 23 '12 at 16:00

4 Answers4

4

Run the javaw executable, not java.

Starkey
  • 9,673
  • 6
  • 31
  • 51
  • I think it will still show a black window because batch files always do. – Sarel Botha Jul 23 '12 at 16:01
  • I guess it will work. The black window does pop up but then goes away. I'd rather it didn't show up at all, but I can live with this. Is there any way to get rid of the console window altogether? – Steve Cohen Jul 23 '12 at 16:06
  • 1
    Use jsmooth to make an exe with a pretty icon. It's really easy to use. – Sarel Botha Jul 23 '12 at 16:06
  • @Sarel: Probably, but the window will go away quickly. `javaw` is a Windows subsystem app, and as such will start and separate from the console, letting it continue/exit immediately. – cHao Jul 23 '12 at 16:06
  • If the batch file doesn't do anything complicated, you should be able to replace it with a shortcut. – Harry Johnston Jul 23 '12 at 23:51
0
  1. Use jsmooth to create an exe. http://jsmooth.sourceforge.net/. It will also detect the location of Java and if the user doesn't have it installed offer to download it for the user.
  2. If you don't mind it flashing the black window when you run the .bat file use javaw -jar myapp.jar in your batch file.
Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
  • What does start /b do for you? Just using javaw the black window flashes for a second, then goes away. – Steve Cohen Jul 23 '12 at 16:20
  • I guess you don't need that with javaw. If you could start the batch file with start /b then the batch file won't flash the black window. I'm guessing a user would double-click the .bat file though. – Sarel Botha Jul 23 '12 at 16:41
0

Perhaps making it a exe file by: http://viralpatel.net/blogs/convert-jar-to-exe-executable-jar-file-to-exe-converting/

Or by doing this:

@echo off
start /B server.jar [arg1] [arg2]  
start /B server.jar [arg3] [arg4]
@echo on

Found here: Launch .jar files with command line arguments (but with no console window)

Community
  • 1
  • 1
Ertyui
  • 858
  • 9
  • 18
0
@echo off
cd C:/link
javaw -jar jarfile.jar

Use this for your batch file.

Jeff Demanche
  • 624
  • 7
  • 25