Skip to main content

Eclipse-how to do "java Sample 55 8"?

1 reply [Last post]
harmonizedchaos
Offline
Joined: 2007-03-29
Points: 0

If you use the command-line environment to compile and run a java program called Sample.java instead of using Eclipse, you could compile by writing "java Sample 30 5" or replace the 30 and 5 with other numbers (lets suppose the Sample.java needs 2 int inputs). How would you do the equivalent of that when using Eclipse?

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shekargowda
Offline
Joined: 2003-06-13
Points: 0

You can use following code read the input from keyboard.

try{
String value;
System.out.print("Question:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
value = br.readLine();
}catch(Exception ex){}

In Eclipse, You can enter the value using "Console" window. If it is not visible, then you can enable it by goign Eclipse Tools > Window > Show Views > Basic > Console