Does Java have the ability to tell the last time a class was modified when loading it? These classes may or may not be bundled in a .zip. Is there a generic way to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no generic way to do this. you can however, get the url from which a class was loaded using
class.getProtectionDomain().getCodeSource().getLocation()(note, some of those methods can return null, be sure to read the javadocs). you could then use the url to get either the modified time of the jar (or the entry inside the jar if that was included), or the class file itself if it is a standalone file (if it’s a remote url, you may be able to use some http headers to get a last modified time as well)..