Have a jar file of an application, there are 2 different external configuration files which needs to be execute during execution of jar file as the backend code of application needs some property reading from these config files.
Question is how can I use these config files, so that while executing the jar , these config files can be considered. Should there be some path specified at code level for config files or some more argument to be added in "java -jar" command. Though this seems to be a basic java development question , yet very new to software development and any sort of suggestion will be helpful.
executing jar by command line " java -jar ExecutableJAR.jar"
Edit : The data inside These configuration files are though not fixed and the key value pairs inside them are suppose to be change based on environment the jar executes. Will that makes any change in the approach , or using the classPath method still works ?
MyClass.Main class is on "org.framework.emulator" package and the execution of main class starts some other service class which is in "org.framework.emulator.service" package. This service class needs those 2 external config file properties to read from.
Currently have these config files (file1 , file2) in ".txt" format in "C:\User\lib" folder. So , do I need to provide the relative path of "file1 and file2" in service class code , and also include the "C:\User\lib" path in classpath option as well ?
-jarbut with-classpathand include the directory in which your config files reside as part of the classpath, along with the jar itself.java -classpath ExecutableJAR.jar;C:\User\lib a.b.c.Main. Odd directory btw. You shouldn't normally create directories off the root