Thursday, October 29, 2015

I want the app to be flexible enough during run-time

In Eclipse IDE, the simplest way to configure class-path is to create a source folder. It is so clean and easy. But when using ANT to package a JAR, class-path is done in the following way:
<project ...>
   <target name="build">
      <jar destfile="./program.jar">
         <manifest>
            < attribute name="Main-Class" value="..."/>
            < attribute name="Class-Path" value="..."/>
         </manifest>
      </jar>
   </target>
</project>
Usually class-path is useful in referencing the library path. But I never though it can be use to reference configuration file, the file which usually in XML or properties pattern. Assuming configuration files were located at config_path, the class-path would be look like this:
<project ...>
   <target name="build">
      <jar destfile="./program.jar">
         <manifest>
            < attribute name="Main-Class" value="..."/>
            < attribute name="Class-Path" value="config_path/ lib_path/the.jar ..."/>
         </manifest>
      </jar>
   </target>
</project>
With this approach, I can have a greater flexibility to configure the application's behavior in anytime during run-time.

No comments: