Is there a way to know if a Java program was started from the command line or from a jar file?

前端 未结 7 2008
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 20:45

I want to either display a message in the console or a pop up, so in case a parameter is not specified, I want to know to which should I display

Something like:

7条回答
  •  执念已碎
    2021-02-03 21:05

    You can get all the input arguments with RuntimeMBean.getInputArguments(), this can be used to detect when debugging is enabled.

    EDIT: However, the -jar argument isn't one of them. :(

提交回复
热议问题