Results 1 to 2 of 2
  1. #1
    paulanon is offline Member
    Join Date
    Apr 2011
    Rep Power

    Default Finding path to my command line tools from Java

    I have several command line tools that I'm wrapping with Java.Swing as GUI. I'm thinking I'll probably create a .jar (or wrap .jar into a .exe for Windows) and put my command line tools in the same folder as the Jar (or as a sub-folder). But how do I get the absolute path for my command line tools? Maybe I can detect the path of the Jar file and take a relative path. How do I get the path of the Jar file? I'm pretty new to Java, so I'm open to other suggestions as well.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    Create a new File object (eg something like new File("temp")), this gives a File object with a path relative to the jar (as long as you do not specify any path information when creating the File), and you can use its absolute path to get its location.

Similar Threads

  1. Command line args for your java app!
    By aadem in forum New To Java
    Replies: 2
    Last Post: 03-04-2011, 10:05 PM
  2. Replies: 2
    Last Post: 07-02-2010, 03:20 PM
  3. Replies: 2
    Last Post: 03-31-2010, 01:26 AM
  4. Java command line
    By agouzoul in forum New To Java
    Replies: 2
    Last Post: 04-02-2008, 01:12 PM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts