0

I have created a console based jar program. To be able to run it with jarfile.jar or by clicking on it, I went into the registry editor and edited HKEY_CLASSES_ROOT > jarfile > shell > open > command > (Default) from [...]javaw.exe[...] to [...]java.exe[...]. It worked, but not immediately - I had to change default program and then change it back a couple of times and do a lot with it (I don't remember exactly). There are two drawbacks to this method: one, executable jar files that aren't meant to be run with console will now have one and that's kind of annoying; two, if I want to release this program publicly, everyone who wants to use it will have to do the same thing or run it with java -jar jarfile.jar.

Therefore, I'm wondering if there's a way to edit the jar's main class to open its own console window that won't be blocked by javaw.exe, so that I can run the jar file with javaw. I'm thinking something like openConsoleWindow(); outputTo(theNewWindow()); inputFrom(theNewWindow());

The Amateur Coder
  • 789
  • 3
  • 11
  • 33
H.v.M.
  • 1,348
  • 3
  • 16
  • 42

1 Answers1

0

Correct me if I'm wrong - you want to launch your .JAR file without using a command line? I'm not aware of any way to do this just by opening the jar, however you can always make a script that's that will do the command-line stuff for you, which only requires opening. That or a form of launcher.

Kieran
  • 43
  • 1
  • 5
  • It is possible, but by default it's opened by javaw.exe which does not show the console window, and making it open with java.exe has the drawbacks I described in the OP, so I was looking for a way to create a console window in the java code that hopefully is not blocked when running with javaw. I'd rather just be able to run the jar directly rather than with a script. – H.v.M. Feb 18 '14 at 16:03
  • @Blrp another solution could be that if your program detects whether java or javaw got used and when you used javaw it would relaunch itself with `cmd.exe /c start java parameters_go_here` to get the console window – masterX244 Feb 13 '15 at 17:31