![]() |
| Advertisement | |
|
|
|
11-06-2005, 12:54 AM |
#1 |
|
Posts: n/a
|
Hello.. I have a simple question if someone may know the answer.... If I run some java program from jar file, can I get phisical location of that jar file dinamicly? I mean if I have main class let's say: "org.classes.main" packed into "C:\jarfile.jar" (or "/usr/home/me/jarfile.jar" can I dinamicaly get location of that jar? I want to use it as an resource, but don't want to be bind to single jar name... Thanks, FrenKy |
|
11-06-2005, 01:00 AM |
#2 |
|
Posts: n/a
|
FrenKy, while
high on whiteboard markers, wrote: > Hello.. > I have a simple question if someone may know the answer.... > If I run some java program from jar file, can I get phisical location > of that jar file dinamicly? > I mean if I have main class let's say: > "org.classes.main" > packed into "C:\jarfile.jar" (or "/usr/home/me/jarfile.jar" > can I dinamicaly get location of that jar? > I want to use it as an resource, but don't want to be bind to single > jar name... File moduleFile = new File (YOURCLASSHERE.class.getProtectionDomain() .getCodeSource().getLocation().toURI()); -- Of making better designs there is no end, and much refactoring wearies the body. |
|
11-06-2005, 01:03 AM |
#3 |
|
Posts: n/a
|
FrenKy, while
high on whiteboard markers, wrote: > Hello.. > I have a simple question if someone may know the answer.... > If I run some java program from jar file, can I get phisical location > of that jar file dinamicly? > I mean if I have main class let's say: > "org.classes.main" > packed into "C:\jarfile.jar" (or "/usr/home/me/jarfile.jar" > can I dinamicaly get location of that jar? > I want to use it as an resource, but don't want to be bind to single > jar name... File jarFile = new File (org.classes.main.class.getProtectionDomain() .getCodeSource().getLocation().toURI()); -- Of making better designs there is no end, and much refactoring wearies the body. |
|
11-06-2005, 07:04 AM |
#4 |
|
Posts: n/a
|
On 5 Nov 2005
16:54:40 -0800, "FrenKy" <> wrote, quoted or indirectly quoted someone who said : >can I dinamicaly get location of that jar? see http://mindprod.com/jgloss/where.html -- Canadian Mind Products, Roedy Green. http://mindprod.com/ Java custom programming, consulting and coaching. |
|
11-06-2005, 08:05 AM |
#5 |
|
Posts: n/a
|
Roedy Green,
while high on whiteboard markers, wrote: > see http://mindprod.com/jgloss/where.html You should take me out of your killfile so you don't reply to questions that I've already answered. -- Of making better designs there is no end, and much refactoring wearies the body. |
|
11-06-2005, 11:49 AM |
#6 |
|
Posts: n/a
|
All solutions
work like a charm I went with File jarFile = new File (org.classes.main.class.getProtectionDomain() .getCodeSource().getLocation().toURI()); Thanks all! Nick |
|
| Advertisement | |
|
|
|