I want to run my project in the command line with the java command but I get an error,
input.txt (no such file or directory)
In my program I am reading from the file input.txt and when I compile and run the program from eclipse it works completely fine without any problems, but with the java command I keep on receiving that error.
My project is structured as so
Project
- src
- bin
- input.txt
The command I am running is(exact path and classname not given)
java -cp Path/to/Project/bin classname
Advertisement
Answer
If you run the command from project directory then it will work fine. But If you run command from any other directory then it will search in that directory for file input.txt
so error will occur.