Results 1 to 3 of 3

Thread: What are Command-Line Arguments in Java?

  1. #1
    MorganCooper is offline Senior Member
    Join Date
    Dec 2009
    Posts
    233
    Rep Power
    3

    Default What are Command-Line Arguments in Java?

    I am learning java programming language. Right now I have little bit knowledge of JAVA. I want to know how command line arguments are passed in Java. If you are having any info then reply me. It can helpful to me. Thanks in advanced.

  2. #2
    BellWard is offline Senior Member
    Join Date
    Dec 2009
    Posts
    236
    Rep Power
    3

    Default

    Try to understand following example which is helpful for you. Refer following program to Command-Line Arguments in Java:

    Code:
    public class CmdArgsDemo{
        public static void main(String[] args){
            System.out.println("The following command line arguments were passed:");
            for (int i=0; i < args.length; i++){
                System.out.println("arg[" + i + "]: " + args[i]);
            }
        }
    }

  3. #3
    CoxWatson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    232
    Rep Power
    3

    Default

    You will have to enter the command-line arguments when include the application. For example suppose a Java application called Align sorts lines in a file. To sort the data in a file named test.txt, a user would enter:

    Code:
    java Align test.txt
    When an application is run, the runtime system passes the command-line arguments to the application's main method through an array of Strings.

Similar Threads

  1. Command Line Arguments
    By BrooksGray in forum Programming
    Replies: 1
    Last Post: 06-15-2010, 02:33 PM
  2. Accepting command line arguments
    By Jacory666 in forum Programming
    Replies: 0
    Last Post: 10-17-2009, 09:37 AM
  3. The GRUB command line
    By Macavi6987 in forum Applications
    Replies: 0
    Last Post: 11-22-2008, 12:57 PM
  4. Customize your command line
    By wonlkad in forum General Internet Terms
    Replies: 0
    Last Post: 06-25-2008, 12:55 PM
  5. Command line AD searches
    By wonlkad in forum Technologies
    Replies: 0
    Last Post: 06-25-2008, 12:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48