Results 1 to 7 of 7
  1. #1
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default File access outside Netbeans

    I have a program that I developed using Netbeans. I am new to Java and I think I may have incorrectly specified a file location. The program can find the file and load the data when run from inside Netbeans but when I double click the .jar file it cannot locate the file.

    Here is the line for file access:

    Scanner scanner = new Scanner(new File("./PDDFWERJ.L09"));

    The file resides in the Bidit(my application name) directory. The jar file resides in the dist directory.

    File Structure:

    Bidit (maindirectory for program)
    -PDDFWERJ.L09
    -dist
    -Bidit.jar

    if I change the file access line to this:

    Scanner scanner = new Scanner(new File("PDDFWERJ.L09"));

    it still doesn't work from outside the IDE

    And if I do this:

    Scanner scanner = new Scanner(new File("C:\\Bidding\\PDDFWERJ.L09"));

    and place the file in that directory it still doesn't work. Any help would be appreciated. I know this is very noob but I can't seem to find the answer in the netbeans forums or online tutorials.

    Thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by TimHuey View Post
    ..And if I do this:

    Scanner scanner = new Scanner(new File("C:\\Bidding\\PDDFWERJ.L09"));

    and place the file in that directory it still doesn't work.

    Thanks
    Really? What error message do you get in this case?

  3. #3
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default

    java.io.FileNotFoundException: PDORDERJ.L09 (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    ...

    Once again, if it's run from inside Netbeans it runs fine.

  4. #4
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default

    I just tried this:

    String inputFileName =
    System.getProperty("user.home",
    File.separatorChar + "Bidding") +
    File.separatorChar + "PDDFWERJ.L09";
    try {
    Scanner scanner = new Scanner(new File(inputFileName));

    And still no luck.

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Java Code:
    java.io.FileNotFoundException: PDORDERJ.L09
    But that is not the same name as the File we were discussing above.
    How many files are you working with and Which file is not being found?

  6. #6
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default

    NONE OF THEM! It's so frustrating. I've even done this:

    HOLY MOLY!!!!

    Never mind. While I was making this post I changed somethings in my program but when I ran it I realized the change wasn't getting done. I was forgetting to hit "CLEAN AND BUILD." UGH!!! SO SORRY GUYS! I told you I was new to this. I can't believe it was due to that.

    It works now. "C:\\Bidding\\filenamehere" does the trick.

    I really hope no one pulled their hair out over this. Well, other than me of course.

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2011, 10:55 AM
  2. random file access and GUI
    By leiferouis in forum New To Java
    Replies: 1
    Last Post: 02-19-2009, 05:21 AM
  3. File Access Through Servlets
    By bipinkrishna15 in forum Java Servlet
    Replies: 1
    Last Post: 05-27-2008, 11:58 AM
  4. variable access from another file
    By riadmazloum in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:13 PM

Posting Permissions

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