Home  >  Eclipse

How to Pass Command Line Arguments to Java Program in Eclipse

By Arvind Rai, September 30, 2013
This page is devoted to give step by step idea to take input as augments in java program with eclipse. We have a simple java program which will print the first arguments given as an input in eclipse. Find the java program.

ArgumentsTest.java
package com.concretepage;
public class ArgumentsTest {
	public static void main(String[] args) {
		String s= args[0];
		System.out.println(s);
	}
}
 
Step-1: Right click on java class. Go to Run As and click on Run Configurations.

How to pass command line arguments to java program in eclipse

Step-2: Click on Arguments tab. Enter value in Program arguments. Click on Run . You will see the output in eclipse console.

How to pass command line arguments to java program in eclipse

If we are writing string more than one words, it needs to be enclosed in double inverted comma. And if we are taking input as single word or number, then it should not be enclosed with double inverted comma.
POSTED BY
ARVIND RAI
ARVIND RAI
FIND MORE TUTORILAS


©2018 concretepage.com | Privacy Policy | Contact Us