Run --> Run Configurations --> Arguments (it is the 2nd tab on the right) --> Program arguments
Answer from WuHoUnited on Stack OverflowRun --> Run Configurations --> Arguments (it is the 2nd tab on the right) --> Program arguments
Add this line in your program to accept user's input from the console:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
and then add in.readLine() beside whatever variable you want to accept input from Runtime. Lets say, you want to initialize count variable to the value 1, then, it should be written as
int count = in.readLine();
The value 1 should be inputted in the console after you run the program
eclipse - Input values to a normal JAVA SE program - Stack Overflow
How to get the user input in Java? - Stack Overflow
eclipse - Java input methods? - Stack Overflow
how to pass inputs to java using eclipse? - Stack Overflow
Can I use a file instead of the console to input strings?
Is it possible for me to accept several strings on a single line?
Eclipse has a console, its typically located at the bottom of your java perspective. If its not there just go to Window->Show View->Console.
Have you ever used an input stream reader or a buffered reader?
The following is a start on how
static InputStreamReader input = new InputStreamReader(System.in);
static BufferedReader in = new BufferedReader(input);
Then you can use the buffered reader for taking input during execution.
If I remember correctly, you can actually type in Eclipse's Java console and that will be sent through the standard input stream, System.in (probably depending on the application's run configuration).
However the standard way of doing this is to pass a number of strings on the command line, which will appear as the elements of the String[] parameter to your application's main method.
Alternatively you can get input in via flat files, from a database, through sockets etc. though this is, as you might expect, a lot more complex and should certainly not be considered for a "Hello World" type application. Java web services, for example, do take their input via network sockets rather than via the command line as this latter would restrict them somewhat. ;-)
Using eclipse, you need to update the Run Configuration for a given Class. Provide any arguments you want to pass into the main method.
One of the simplest ways is to use a Scanner object as follows:
import java.util.Scanner;
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter a number: ");
int n = reader.nextInt(); // Scans the next token of the input as an int
// Once finished
reader.close();
You can use any of the following options based on the requirements.
Scanner class
import java.util.Scanner;
//...
Scanner scan = new Scanner(System.in);
String s = scan.next();
int i = scan.nextInt();
BufferedReader and InputStreamReader classes
import java.io.BufferedReader;
import java.io.InputStreamReader;
//...
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
int i = Integer.parseInt(s);
DataInputStream class
import java.io.DataInputStream;
//...
DataInputStream dis = new DataInputStream(System.in);
int i = dis.readInt();
The readLine method from the DataInputStream class has been deprecated. To get String value, you should use the previous solution with BufferedReader
Console class
import java.io.Console;
//...
Console console = System.console();
String s = console.readLine();
int i = Integer.parseInt(console.readLine());
Apparently, this method does not work well in some IDEs.
Probably your input is a Scanner, so just use nextLine() to get a line of text. That will wait for the user to enter an arbitrary amount of text and press enter, then you'll get all the text they entered.
Soln:
public static void main(String[] args) {
System.out.println("Enter the phrase");
String line;
try {
BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
while ((line = input.readLine()) != null) {
System.out.println(line);
if(!line.isEmpty()) {
StringTokenizer st = new StringTokenizer(line);
while (st.hasMoreTokens()) {
System.out.println("token=" + st.nextToken());
}
}
}
input.close();
} catch (IOException e){
e.printStackTrace();
}
System.out.println("DONE");
}
To pass arguments to a Java program via Eclipse, you should use the Arguments tab in Run > Run Configurations. Example:
Arguments

Code
public static void main(String[] args) {
System.out.println(args[0]);
System.out.println(args[1]);
System.out.println(args[2]);
}
Result
33
twitter
400.23
you can pass your input parameters in following way in Eclipse: click menu Run -> Run Configurations -> Arguments in Program arguments put your arguments, which will be loaded to "String [] args" you could just separate your arguments by space:
e.g.
1 2 3
and your args = {1,2,3}