Can I use the classpath to override a file in a jar that is being run?

后端 未结 4 650
情深已故
情深已故 2020-12-18 19:45

I have a JAR file that contains an application as well as configuration files for that application. The application loads configuration files from the classpath (using

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 20:02

    Why not just invoke the application without specifying -jar and instead name the application main class explicitly? This will allow you to put both your new-config and the application.jar on the classpath in the required order:

    e.g. (assuming "new-config" is a directory containing the overridden properties file)

    java -cp new-config:application.jar Application.Main.Class
    

    I believe the name of main class can be found in the MANIFEST.MF file inside the jar ....

提交回复
热议问题