Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9087
| From | Philipp Kraus <philipp.kraus@flashpixx.de> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | get path of a Jar file |
| Date | 2011-10-22 11:54 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <j7u3th$9dr$1@online.de> (permalink) |
Hello,
I would like to extract a directory of a Jar file. I read the path of
my Jar file with:
String l_jarfile =
Class.forName("class_within_the_jar").getResource("").toString();
l_jarfile = l_jarfile.substring(9,
l_jarfile.lastIndexOf(".jar!")) + ".jar";
This does not work on MS Windows systems (unix and OSX work correct
with this code).
If the Jar files is stored under a path like "C:\Users\myuser\Java
Files\myjar.jar" (with a space)
the JarFile-Object can't locate the file, because the space within the
directory is changed to %20
I need a solution to detect the location of a Jar File in a class. How
can i Do this in a correct way?
Thx
Phil
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
get path of a Jar file Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-10-22 11:54 +0200
Re: get path of a Jar file Lew <lewbloch@gmail.com> - 2011-10-22 08:52 -0700
Re: get path of a Jar file Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-22 21:19 +0000
Re: get path of a Jar file Steven Simpson <ss@domain.invalid> - 2011-10-24 21:07 +0100
Re: get path of a Jar file Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-10-30 18:49 +0100
csiph-web