How to get current jar path

Discussion in 'Java' started by loris_p, Jun 10, 2008.

  1. loris_p

    loris_p Guest

    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, Jun 10, 2008
    #1
    1. Advertising

  2. loris_p

    loris_p Guest

    I solved using property java.class.path and checking if the jar
    exists.
    Bye.
     
    loris_p, Jun 10, 2008
    #2
    1. Advertising

  3. loris_p

    EJP Guest

    loris_p wrote:
    > I need the path where the jar is. How can I do?


    Class.getProtectionDomain().getCodeSource().getLocation()
     
    EJP, Jun 11, 2008
    #3
  4. loris_p

    Roedy Green Guest

    On Tue, 10 Jun 2008 14:46:15 -0700 (PDT), loris_p
    <> 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
     
    Roedy Green, Jun 11, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    641
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,800
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,879
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    706
    Arnold Peters
    Jan 5, 2005
  5. markspace
    Replies:
    2
    Views:
    500
    markspace
    Oct 7, 2011
Loading...

Share This Page