Results 1 to 10 of 10
  1. #1
    dojob is offline Member
    Join Date
    Jul 2013
    Posts
    52
    Rep Power
    0

    Default Input and display * in command line argument

    How to input and display * in command line argument?

    The book say that it should be input with quotation mark but
    I try java Test *; java Test "*"; and java Test '*' and none of them will display *
    java Test * and java Test "*" displays all the file in the same directory
    java Test '*' display '*'


    Java Code:
    public class Test {
      public static void main(String[] args) {
        for(int i = 0; i < args.length; i++){
                System.out.println(args[i]);
        }
     }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Input and display * in command line argument

    What OS are you using?

    I'm on Windows 7, and using * prints out every file in my working directory, using '*' prints out '*' including the quotes, and using "*" prints out a single * without the quotation marks.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    dojob is offline Member
    Join Date
    Jul 2013
    Posts
    52
    Rep Power
    0

    Default Re: Input and display * in command line argument

    well, I am using Windows 7 too

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Input and display * in command line argument

    I'm not sure what to tell you. Passing the * inside " " quotation marks works for me.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    dojob is offline Member
    Join Date
    Jul 2013
    Posts
    52
    Rep Power
    0

    Default Re: Input and display * in command line argument

    Well, I discover that it is problem on my own computer. Does anyone know how to resolve it?

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Input and display * in command line argument

    Are you *sure* you're using quotation marks? Can you copy and paste the full text of your command prompt, including your input?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    dojob is offline Member
    Join Date
    Jul 2013
    Posts
    52
    Rep Power
    0

    Default Re: Input and display * in command line argument


  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Input and display * in command line argument

    Interestingly, this page says that expanding the * is up to the program, not Windows. What version of Java are you using?

    Pass a string containing the * (asterisk) character as a command line argument in Windows Shell - Stack Overflow
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    dojob is offline Member
    Join Date
    Jul 2013
    Posts
    52
    Rep Power
    0

    Default Re: Input and display * in command line argument

    Thanks, I was using JDK 7 update 5 previously and it works perfectly fine after I update it to latest update(update 40)

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Input and display * in command line argument

    That is really weird. I can't find a bug report for that. Oh well, at least you got it sorted out.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. my command-line argument doesn't pass values!
    By niloufar in forum New To Java
    Replies: 17
    Last Post: 10-17-2012, 07:04 AM
  2. Command line argument
    By denisatandi in forum New To Java
    Replies: 8
    Last Post: 10-16-2012, 11:37 PM
  3. Maximum length of Command Line Argument
    By balamurugan.murthy in forum Advanced Java
    Replies: 11
    Last Post: 05-21-2010, 04:45 PM
  4. Command line argument help...
    By arson09 in forum New To Java
    Replies: 4
    Last Post: 05-06-2010, 05:49 PM
  5. Command Line Argument
    By right2001 in forum New To Java
    Replies: 6
    Last Post: 02-17-2009, 02:08 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
  •