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

    Default .jar file cannot find folders in the same directory as the .jar file

    Hi There,

    I am using NetBeans 7.0 to do my honours project to solve the Traveling Salesman Problem, and came across a problem i'm having.
    I built my project and now have a .jar file which i can run from command line, but the project uses two folders where my datasets are found. If my .jar file and folders are all in my home folder i have no problem, but when i take them and put them in another folder, the .jar file complains and says that it cant find the folders (apparently its looking for the folders in my home directory).

    How do i configure my jar file to find the folders in the same directory the jar file is located and not my home directory?

    The code i'm using to locate the folders are as follows:

    File file = new File("optimal_datasets");
    String[] datasets = file.list();
    for(String data : datasets){
    jComboBox.addItem(data);
    }

    Thanks
    Ronald Mariah

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: .jar file cannot find folders in the same directory as the .jar file

    To see where the program is looking for the File: file, print out its absolutePath.

Similar Threads

  1. File folders
    By lakshmibvaraprasad in forum New To Java
    Replies: 2
    Last Post: 08-09-2011, 07:56 PM
  2. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  3. [SOLVED] File chooser selecting file from directory...?
    By prabhurangan in forum AWT / Swing
    Replies: 12
    Last Post: 06-18-2008, 04:08 AM
  4. Replies: 0
    Last Post: 05-13-2008, 06:16 AM
  5. Replies: 2
    Last Post: 11-27-2007, 01:45 PM

Tags for this Thread

Posting Permissions

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