Results 1 to 5 of 5
  1. #1
    RedSix is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default data.txt not found

    Hi,

    I hope some can help me out with this.

    I have a program and it runs fine from the Command Prompt using javac then running it. The program holds some data in a .txt file.

    I have put the code into Eclipse, but I do not know how/where to add the txt file to the program. The debugger keeps saying file not found even though it is within the same 'src>default package' folder.

    I keep reading I have to make it into a .jar file before I can include it, but then I read you cannot use them in this form.

    So how can I add the data.txt file into the program/IDE?

    Million thanks for any help, I am quite stuck and under pressure. :o

    Thank you

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Make sure eclipse is set to copy resources from the src folder to the bin (output) folder.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    RedSix is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    Thanks OrangeDog!!!!

    How is that done?


    Set eclipse to copy resources to that?

    I right click on the src folder, but see no option for that.

    +Rep

    Please help :)


    EDIT - I have deleted the txt file fom the project and have a new one to add and try again.

    I right click on the 'src' folder in the Package Explorer window. I go New>File and enter a name 'mydata.txt' which is placed in the 'src' folder and I click OK. Copy and paster the files contents into the file, save, and try to run, but it says:



    File not found: mydata.txt
    EXCEPTION: books.txt (The system cannot find the file specified)
    java.io.FileNotFoundException: books.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileReader.<init>(Unknown Source)
    Last edited by RedSix; 04-23-2009 at 01:30 AM.

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    I think it's on by default, I can't find the settings right now. Can you confirm that it is being copied to the output folder?
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    RedSix is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    I have the class files now added into NetBeans now also, how can I add the txt file to a project in this even?

    EDIT - I have is sorted now. The txt file was not located withing the / of the project space.
    Last edited by RedSix; 04-23-2009 at 11:12 AM.

Similar Threads

  1. No JVM found error
    By rocky05 in forum New To Java
    Replies: 1
    Last Post: 01-27-2009, 03:41 PM
  2. no jre,jvm found error
    By rocky05 in forum Eclipse
    Replies: 2
    Last Post: 01-27-2009, 03:38 PM
  3. Web Application not found
    By adtd8 in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 07-28-2008, 02:05 AM
  4. GeoPoint Not found
    By nvidia in forum NetBeans
    Replies: 2
    Last Post: 05-28-2008, 09:31 PM
  5. 404 Not Found
    By mary in forum Java Servlet
    Replies: 5
    Last Post: 11-07-2007, 10:15 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
  •