Results 1 to 7 of 7
Thread: File access outside Netbeans
- 08-30-2009, 12:16 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 50
- Rep Power
- 0
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
- 08-30-2009, 12:21 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
- 08-30-2009, 02:19 AM #3
Member
- Join Date
- Aug 2009
- Posts
- 50
- Rep Power
- 0
...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.
- 08-30-2009, 04:34 AM #4
Member
- Join Date
- Aug 2009
- Posts
- 50
- Rep Power
- 0
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.
- 08-30-2009, 06:10 AM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
But that is not the same name as the File we were discussing above.Java Code:java.io.FileNotFoundException: PDORDERJ.L09
How many files are you working with and Which file is not being found?
- 08-30-2009, 06:31 PM #6
Member
- Join Date
- Aug 2009
- Posts
- 50
- Rep Power
- 0
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.
- 08-30-2009, 08:52 PM #7
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
Getting access denied error while importing file using input type="file" with IE7
By sarang1 in forum Advanced JavaReplies: 6Last Post: 02-10-2011, 09:55 AM -
random file access and GUI
By leiferouis in forum New To JavaReplies: 1Last Post: 02-19-2009, 04:21 AM -
File Access Through Servlets
By bipinkrishna15 in forum Java ServletReplies: 1Last Post: 05-27-2008, 10:58 AM -
variable access from another file
By riadmazloum in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 07:13 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks