Home Tutorial Java Core Commandline Passing argument at command line using Core Java

 
 

Share on Google+Share on Google+
Passing argument at command line using Core Java
Posted on: March 15, 2010 at 12:00 AM
Advertisement
This example demonstrate how value accepted from the command line. All argument need to placed at the command line at the time of executing your program.

How to pass Command Line Argument using Core Java

Description :

This example demonstrate how value accepted from the command line. All argument need to placed at the command line at the time of executing your program. 

class CommandLineArgs{

public static void main(String args[]){

intl=args.length;

int sum=0;

for(int j=0;j<l ;j++)

{

sum=Integer.parseInt(args[j])+sum;

}

System.out.println("The Sum of All Elements entered at command line is : " + sum);

}

}

output

 C:\commandLineArgument>

set path=C:\Program Files\Java\jdk1.6.0_11\bin

C:\commandLineArgument>javac CommandLineArgs.java

C:\commandLineArgument>java CommandLineArgs 12 5 

The Sum of All Elements entered at command line is : 17

Advertisement

Related Tags for Passing argument at command line using Core Java:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 15, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com