java - can't take name of running jar -
i know there lot of similar questions , answers. no 1 solution work me! don't understand why(( have runnable jar example 'program.jar' , inside of want take name of jar (namely program.jar). i've tried following:
classinsidejar.class.getprotectiondomain().getcodesource().getlocation().getpath()
new java.io.file(classinsidejar.class.getprotectiondomain().getcodesource().getlocation().getpath())
new file(".")).getabsolutepath()
(and different variations getcanonicalpath etc)classloader.getsystemclassloader().getresource(".").getpath()
and in these cases can take path jar. example full path j:/folder/program.jar
. can see j:/folder
.
what's mistake? i'm trying name of jar in main class , others.
i've tried run jar double click , command line. result same
try this:
(new file(classinsidejar.class.getprotectiondomain().getcodesource().getlocation().touri())).getname();
Comments
Post a Comment