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

    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
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    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, 09:05 PM
  2. Replies: 2
    Last Post: 07-02-2010, 02:20 PM
  3. Replies: 2
    Last Post: 03-31-2010, 12:26 AM
  4. Java command line
    By agouzoul in forum New To Java
    Replies: 2
    Last Post: 04-02-2008, 12: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, 12: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
  •