C
Chameleon
I want to know in which path is application.
Until now I use the following super_dumb code:
application.jar : the jar file
subtitle/MainFrame.class : the main() class
try {
// get application path
rootPath =
URLDecoder.decode(ClassLoader.getSystemResource("subtitle/MainFrame.class").getPath().replaceAll("(application\\.jar!/)?subtitle/MainFrame\\.class$|^(file\\?/",
""), "UTF-8");
} catch (UnsupportedEncodingException ex) {
rootPath = "";
}
Is there a better approach?
Thanks!
Until now I use the following super_dumb code:
application.jar : the jar file
subtitle/MainFrame.class : the main() class
try {
// get application path
rootPath =
URLDecoder.decode(ClassLoader.getSystemResource("subtitle/MainFrame.class").getPath().replaceAll("(application\\.jar!/)?subtitle/MainFrame\\.class$|^(file\\?/",
""), "UTF-8");
} catch (UnsupportedEncodingException ex) {
rootPath = "";
}
Is there a better approach?
Thanks!