ClassLoader bladeClassLoader = BladeCLI.class.getClassLoader();

URL url = bladeClassLoader.getResource("/libs/blade.jar");

JarURLConnection jarUrlConnection = (JarURLConnection)url.openConnection();

JarEntry jarEntry = jarUrlConnection.getJarEntry();

Long bladeJarTimestamp = jarEntry.getTime();

1. 先得到改Jar包的URL

2.然后通过JarUrlConnection得到JarEntry

3.然后再通过JarEntry得到时间戳

Note: 直接通过JarUrlConnection只能得到该Jar包的时间戳,不能得到其内嵌Jar包的时间戳。

05-22 00:15