Java version Info

Submitted by code_admin on Wed, 07/25/2018 - 10:31

To add version information to a Java Application.

In the main proejct create a class called setVersion as follows
In the constructor call setVersionInfo for the App and also register any libraires required.

  1. package xxx;
  2.  
  3. import metcarob.com.common.general.VersionInfo;
  4.  
  5. public class setVersion {
  6.  
  7.     public static void setVersion() throws Exception {
  8.         VersionInfo.setVersionInfo("AdminWebServ","**ArtifactID**");       
  9.         VersionInfo.getVersionInfo().registerLibrary(metcarob.com.common.setVersion.ver);
  10.     }
  11. }

Call this class at the start of the main method:

  1. try {
  2.     setVersion.setVersion();
  3. } catch (Exception e2) {
  4.     e2.printStackTrace();
  5.     return;
  6. }
  7. log.log(Level.INFO, "  App Name:" + VersionInfo.getVersionInfo().toString());
RJM Article Type
Work Notes