How to get current jar path  
Author Message
loris_p





PostPosted: 2008-6-11 5:46:00 Top

java-programmer, How to get current jar path Hi! I'm working on an application that should run on an usb pen using
an embedded Derby DB. I need the DB to be on the USB pendrive with the
application.
Pen filesystem should look like this:

/
- application/
- application.jar
- lib/
- embeddedDB

using "user.dir" system property i get the path from where the jar has
been launched, while I need the path where the jar is. How can I do?
 
loris_p





PostPosted: 2008-6-11 6:03:00 Top

java-programmer >> How to get current jar path I solved using property java.class.path and checking if the jar
exists.
Bye.
 
EJP





PostPosted: 2008-6-11 11:02:00 Top

java-programmer >> How to get current jar path loris_p wrote:
> I need the path where the jar is. How can I do?

Class.getProtectionDomain().getCodeSource().getLocation()
 
 
Roedy Green





PostPosted: 2008-6-11 12:39:00 Top

java-programmer >> How to get current jar path On Tue, 10 Jun 2008 14:46:15 -0700 (PDT), loris_p
<email***@***.com> wrote, quoted or indirectly quoted someone
who said :

>using "user.dir" system property i get the path from where the jar has
>been launched, while I need the path where the jar is. How can I do?

see http://mindprod.com/jgloss/wherejars.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com