Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes i changed a folder name and now my program wont run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "i changed a folder name and now my program wont run" Watch "i changed a folder name and now my program wont run" New topic
Author

i changed a folder name and now my program wont run

charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49
I changed the name of a folder so that it would meet the requirements for my assignment submission and now my program wont run in the command window. its saying it can't find the .txt files.
However, the program runs without any problems in JCreator.

i have a folder called Ass_5 with 3 folders in it - src, files and classes as well as build.bat and run.bat. src has the two .txt files, a class file and the java source file. the other two folders are empty. everything is in the right place isnt it?
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624


1. What error message are you getting? Knowing that can help us determine your problem.

2. Which directory did you rename?

3. I assume you are running your program using the run.bat file. Does a it reference the old directory and therefore need to be updated?
charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49
1. the error is saying java.io.FileNotFoundException: Cities.txt (The system cannot find the file specified)

Its saying that for the Temperatures.txt file as well

2. i renamed the Ass_5 directory. It was called CitiesAndTempsApp before that I think.

3. not sure what you mean. in the command prompt window i typed in build and then run CitiesAndTemperatures
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

So it sounds like the program is running. It is just that it throws an exception that it cannot find your Cities.txt file while it is running.

How are you trying to load that Cities.txt file in your code? Can you post the snippet of the code you are using to load the Cities.txt file? Is that code using a hard coded file path that has your old directory name?
charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49


yeah it does run fine, it just wont find the .txt files
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

charlie mills wrote:

yeah it does run fine, it just wont find the .txt files

Not to nit pick too much, but in programming, detail and precision are very important. So your subject of "...my program won't run" is very different than what is actually happening which is that your program is failing. ;) It's just that that difference makes a huge difference in how to go about troubleshooting the problem. See the Tell The Details FAQ for more info.

Based on the code you have, it is going to look for the txt files in whatever directory the program is started from (unless the user.dir system property is getting set on the command line).

1. Are in the Ass_5 directory when you issue the run command? If not, try changing into that directory and see if it works.

2. I take it that the run.bat file was provided to you by your teacher? Or did you write it?

I have to run to a meeting, so my next reply will be delayed. But someone else might be able to jump in and pick things up to help you.



charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49
i am in the Ass_5 directory when i build and run. it automatically starts in projects and i filter down by using cd Ass_5.
yeah, my teacher did give me the run.bat
charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49
i've worked out where i've gone wrong now. JCreator was running the classes from the src directory and not the classes directory. i copied the .txt files across to the classes directory and its all working perfectly now.

thanks for your help
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Great. I'm glad you got it working. And I was glad to help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i changed a folder name and now my program wont run