for now i could use clazz.getClassLoader().getResource(class.getName()), then i substring the URL to get the jar file’s location, but i really want to know if there is any better way to do it.
is there any API for this? thank you.
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.
If your class is called Foo
classLocation will contain the URL where the class was loaded from. Either a folder for a stand alone class or a jar/zip.