My contemplations and diurnal novelties are publicized here


Following is the piece of code to get your executing Jar name and its modified date. You can use these info for logging purpose:-

// Get File Jar File

String jarFileName = new java.io.File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName();

JarFile jf = new JarFile(jarFileName);

// Get Manifest

ZipEntry manifest = jf.getEntry(“META-INF/MANIFEST.MF”);

// Get Manifest date time

long manifestTime = manifest.getTime();

Date date = new Date(manifestTime );

DateFormat formatter = new SimpleDateFormat(“YYYY-MM-dd HH:mm:ss:SSS”);

String dateFormatted = formatter.format(date);            

log.info(“Executing Jar :” + jarFileName + ” with modified date: “ + dateFormatted);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: