Passing a file into a Java program as a paramater

I'm trying to pass a .txt file as a paramater into my java program. The line that reads in the file is:

Scanner in = new Scanner(System.in);

My program is titled SetTest and the file I'm trying to read is Ted.txt. If I go to a Windows 7 command prompt I create a temp folder and compile my porgram there creating SetTest.class. Also in that folder is Ted.txt. From that temp directory I then issue the command:

java SetTest < Ted.txt

Everything works great.

My question is how do I duplicate this using Eclipse? Where does the file (Ted.txt) need to be located and how do I pass it into my program?

< is the input redirection operator in the shell. When you write java SetTest < Ted.txt, you're executing the command java SetTest without passing any arguments to SetTest and feeding Ted.txt into the program's standard input stream. This is not possible to do in Eclipse.

If you want to read from a file, you should pass a File object as the argument to Scanner's constructor rather than System.in. That's what James meant by "create your Scanner using the file directly".

seep2k, thanks for the reply. I've searched the web for a solution here and it appears you are 100% correct, what you can do from a command prompt "java SetTest < Ted.txt" you can't do from Eclipse. Thanks for the help.

For the record I can change my code as you said to use the line: Scanner in = new Scanner(new File("Ted.txt")); and everything works fine in Eclipse. However, going back to my initial question, I'm learning to use Eclipse at the same time I'm learning Java and I wanted to see if I could use Eclipse to do this. Now I know I can't. Thanks again for this; I just wanted to understand what was possible. Please consider this matter closed.

Instead of hardcoding "Ted.txt" like that you can also use a command line argument as James suggested (which will be accessible through the array that's passed as an argument to main). Command line arguments can be passed through Eclipse (in the run configuration there's a text field for them) or through the command line (by writing java SetTest Ted.txt). So you don't have to change your code and recompile any time you want to use a different file.

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...