Is there a way to check if the jar was launched from command line via 'java -jar test.jar' or via double click in explorer? I want it to start in nogui mode if it was executed from the command prompt.
Asked
Active
Viewed 550 times
1 Answers
3
No. There is no way to determine how it was launched. You could pass a command line argument like
java -cp . my.package.Example -nogui
And then parse the argument in your main()
method to control the "command line" or "gui" mode.

Elliott Frisch
- 198,278
- 20
- 158
- 249
-
Thank you. So that's why I couldn't find anything about this. – schnellboot Jan 25 '15 at 01:55