aspose file tools*
The moose likes Beginning Java and the fly likes unable to take command line inputs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "unable to take command line inputs" Watch "unable to take command line inputs" New topic
Author

unable to take command line inputs

akila sekaran
Ranch Hand

Joined: Jun 12, 2012
Posts: 48

This program is supposed to take in inputs but this ones printing just the default print statements..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Hello Campbell Ritchie. You are 99 years old!

Worked perfectly
What are you writing at the command-line?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
And welcome to the Ranch
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
How do you run it? From a shell window or from an IDE?



Bye,
Nicola
Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 187

Output: Hello gaurang 21. You are 21 years old!

It works perfectly...


akila sekaran
Ranch Hand

Joined: Jun 12, 2012
Posts: 48
Campbell Ritchie wrote:Hello Campbell Ritchie. You are 99 years old!

Worked perfectly
What are you writing at the command-line?




i had to use the InputStreamReader to get in the values which worked fine now.. but this code posted works but jus prints without gettin any input from user..
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5264
    
    9

The program is expecting the "input" to be specified on the command line, just as Campbell has shown.

If you're on Windows, you would run it this way:

C:> java Arguments Akila Sekaran 18

And it should work perfectly by giving the output:

Hello Akila Sekaran. You are 18 years old!

Please try to read the replies more carefully next time so you don't have to have multiple people telling you the same thing. Thanks.


Junilu - [How to Ask Questions] [How to Answer Questions]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
akila sekaran wrote: . . . i had to use the InputStreamReader to get in the values . . .
That is not how the args array works. As Junilu Lacar told you, and several other people, you need to enter those data at the command line. Not a reader of any sort.
Stanley Mungai
Ranch Hand

Joined: Dec 09, 2011
Posts: 155

Akila, If I was you I would Do:



Give a beggar a fish; feed him for a day. Teach him how to fish; Feed him for a lifetime.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Not if you want command-line arguments. A BufferedReader reading from System.in might be a better way to take input generally, but the original post was specifically written to use command-line arguments.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to take command line inputs