Your ant
script compiles the java classes and puts them into the build
directory (that's how it should be). This happens in the target named compile. I assume you have put your input file into the src
folder in Eclipse. Eclipse also has a build directory - usually bin
- and copies such files over automtically. (There are filters in the settings which define the file types it won't copy.)
The ant
script does not copy the input file. So it cannot be found, when run from the ant script, but it is found when run from Eclipse.
To copy the input file, add this to the compile target:
<copy todir="${build}">
<fileset dir="${src}" includes="*.txt" />
</copy>
This copies all .txt
files from the src directory to the build directory.
(Note: As mentioned, I assume your text file is in the source directory. If it is not, this is probably not the correct solution.)