Can you tell on runtime if you're running java from within a jar?

后端 未结 8 1556
星月不相逢
星月不相逢 2020-12-09 14:54

I have an application that some of my users run from Eclipse, and others run it by using a jar file.

I want some actions to be done when running from within the jar,

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 15:17

    Another approach is putting information in the manifest file, and testing for if that information is available at runtime.

    If it is, then the code was started with "-jar". Otherwise it was started in another way, e.g. directly from Eclipse.

提交回复
热议问题