Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Question command line arguments

    How to pass * as a command line argument?
    as * is a wild card character when it is passed in command line gives the files in the current directory.
    i want * to be printed on my console how do i do that??

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    can you please post your full command line argument at the moment?

  3. #3
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    java Demo *
    i want * to be printed on my console...

  4. #4
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    E:\shruthi\Nerd's junction\java>java Demo *
    area
    AreaDemo.class
    AreaDemo.java
    awards.class
    BalDemo.java
    Box.class
    BoxDemo.class
    BoxDemo.java
    Cont.class
    Cont.java
    css.class
    css.java
    ddi.class
    ddi.java
    Demo.class
    Demo.java
    Demopack.java
    equalsDemo.class
    equalsDemo.java
    exams.class
    ExcepDemo.class
    ExcepDemo.java
    Exp1.class
    Exp1.java
    Exp2.class
    Exp2.java
    FinallyDemo.class
    FinallyDemo.java
    First.class
    First.java
    getCharsDemo.class
    getCharsDemo.java
    IEducation.class
    IHouse.class
    indexOfDemo.class
    indexOfDemo.java
    InnerClassDemo.class
    InnerClassDemo.java
    IVehicle.class
    java1.zipx
    Loan.class
    LowBalance.class
    mul_inh.class
    mul_inh.java
    multiple.class
    multiple.java
    Narrow.class
    Narrow.java
    NoMatchException.class
    Outer$Inner.class
    Outer.class
    p1
    person.class
    QEqu.class
    QEqu.java
    qmath
    rep.class
    rep.java
    SortString.class
    SortString.java
    sports.class
    StringDemo.class
    StringDemo.java
    student.class
    TaggedArray.class
    TaggedArray.java
    teacher.class
    ThrowDemo.class
    ThrowDemo.java
    ThrowsDemo.class
    ThrowsDemo.java
    TriMul.class
    TriMul.java
    UseStatic.class
    UseStatic.java
    Wide.class
    Wide.java

    This is what is happening when i am trying to print *... y is that???

  5. #5
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Sorry if I seem pedantic but do you have a class called Demo?

  6. #6
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    * is a special wildcard character meaning everyting in the directory

  7. #7
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Yes i do....
    and my pgm goes like this...

    class Demo
    {
    public static void main(String args[])
    {
    for(int i=0;i<args.length;i++)

    System.out.println(args[i]);
    }
    }

    everything else is working fine...
    but when i want to print * taking it as a command line argument it gives me the files in the current directory...

  8. #8
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    ya i know that but i want to take * as a command line argument and print it on my console.. How do i do that???

  9. #9
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    try \* instead of star...let me know if it works

  10. #10
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    NO it doesnt.
    this is what is happening...
    E:\shruthi\Nerd's junction\java>java Demo \*
    \key.bat
    \loc.bat
    \RECYCLER
    \shruthi
    \System Volume Information
    i tried '\*' , "\*", \\* none of them are working...
    i want just a * on my console..
    if i do .* it prints .*
    but if i pass *. it prints the packages name in my directory...

  11. #11
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    :) :) :) i got what i wanted...
    if i pass "*"
    it prints *
    thanks for ur reply.... :) :)

  12. #12
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    ha that is weird it excepts a fully quoted arguement that do no have spaces, any well done another feather in my bow anyhow...

Similar Threads

  1. command line arguments
    By evermore in forum New To Java
    Replies: 5
    Last Post: 03-28-2010, 05:08 AM
  2. command line arguments
    By jttslg in forum Advanced Java
    Replies: 23
    Last Post: 03-24-2010, 05:06 PM
  3. Command-Line Arguments
    By mustachMan in forum New To Java
    Replies: 5
    Last Post: 02-26-2010, 03:13 AM
  4. Command Line Arguments
    By Nakira in forum NetBeans
    Replies: 10
    Last Post: 02-04-2010, 03:45 PM
  5. Command line arguments help
    By may88 in forum New To Java
    Replies: 8
    Last Post: 12-08-2009, 01:20 PM

Posting Permissions

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