Start a java program without the console

不问归期 提交于 2019-11-27 17:57:43
RollingBoy

If you want to start a java program without console popup under windows, this should be helpful: In command prompt type the following:

start javaw -jar -Xms1024m -Xmx1024m crafty.jar

If you want you can also write this as a batch file.

  • You should Create Shortcut of "%ProgramFiles(x86)%\Java\jre6\bin\javaw.exe", let's name it as Minecraft, then
  • edit the Properties of Minecraft shortcut. In the Target textbox, append -jar -Xms1024m -Xmx1024m crafty.jar in the end of javaw.exe
  • change the Start in as the folder which contains the crafty.jar

Double-click the Minecraft icon to star the server.

That's all.

Create a .bat file with

start javaw -jar yourjar.jar arg0 arg1
start javaw -jar yourjar.jar arg0 arg1

will open the console, but close immediately. it is different from running window .exe.

You will always get the command window opening and closing because you are starting it inside a command window or batch script (which launches an implicit command window to run itself). In order not to get a command window you must open the file from "not a command window" i.e. an executable launcher.

Take a look at Launch4j which can run a java program from an exe. It can also hide-away the jar file inside the exe if you like.

http://launch4j.sourceforge.net/

There's a little YouTube clip showing them creating an exe from a jar.

A batch file is a way of starting the command prompt with the code pre-written, using javaw is a way of open then closing the prompt. Like I said a batch is a commands prompt you can't stop it from opening.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!