Posts which you will also like.

Friday, August 3, 2012

Passing Command Line Argument in Eclipse

Passing command line arguments in Eclipse is very easy.We will see step by step procedure to pass command line arguments to a java program using eclipse.

package com.techy.rajeev;

class BadFoodException extends Exception {

class Myexception{
    public static void checkfood(String food)throws BadFoodException{
            System.out.println("Good food :)");
            throw new BadFoodException();
    public static void main(String args[]){
        for(String s: args){
            try {
            } catch (BadFoodException e) {

This is the java program for which we want to pass command line arguments.

Write this program in eclipse IDE and save it.

Now click on the small dropdown icon beside run icon as shown in image:


A drop down menu will appear.Now click on Run Configurations.


Now a new window will appear.This window provide us the settings for the run time configurations of a program.

In this window click on the arguments tab and supply the arguments needed by your program separated via space as delimiter.


Thats it.

More on this at

No comments:

Post a Comment

Your comment may wait for moderation.... Protected by Copyscape Online Plagiarism Tool