0

I am writing a small program in java which is prompting some messages at the console and expects some user input from it. Now what I want to do is when I export my Program from eclipse as an executable .jar, it should open a cmd-window when you start the program via clicking on it. Usually, as a developer, you start your programs via cmd-window already, so you do not need this. But when i send my program to somebody else, i want them to just click on the program and go ahead. How do i manage to make my program open a cmd-window on startup?

PKlumpp
  • 4,913
  • 8
  • 36
  • 64

2 Answers2

2

Only your operating system can decide to start a "cmd-windows" (including a Shell process) BEFORE running the "default" application (java) in order to run the document type (xxx.jar) when you "open" this document by double-clicking.

you say "by double-clicking" therefore your target platform includes a window manager ==> to achieve your platform-independent input/output window, you have better code a "simple" Swing user interface which will run on all classic windowed platform, without any additional setup (except of course java itself).

IF your target operating system is Linux, you can build a SHELL which includes a java launcher at the top of the file, and the inlined binary jar at the bottom of the file (which is used by the shell part of the file in order to start the java interpreter). This is a way which is used by some linux installer. In this case, the shell can "detect" the available window terminal among the 'classic' ones (gnome-terminal, xterm...) and start one to wrap the java startup... But THIS IS MUCH MORE DIFFICULT than coding a Swing application...

soltiz
  • 21
  • 2
0

It depends on your system:

Windows

Ubuntu

Mac

The list goes on...

Community
  • 1
  • 1
Domi
  • 22,151
  • 15
  • 92
  • 122
  • A default solution would be great. So if there are different solutions, I can implement each of them. – PKlumpp Nov 28 '13 at 15:42
  • As mentioned in the other answer, there is no system-independent way of launching your application. – Domi Nov 28 '13 at 15:56