aspose file tools*
The moose likes Beginning Java and the fly likes command line invocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "command line invocation" Watch "command line invocation" New topic
Author

command line invocation

Sanjana Sharma
Greenhorn

Joined: Jan 08, 2011
Posts: 29


and command line invocation : java try a b c

what should the output be?

I get no output at all...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

"try" is a reserved keyword. Did you manage to compile it ??


[My Blog]
All roads lead to JavaRanch
Sanjana Sharma
Greenhorn

Joined: Jan 08, 2011
Posts: 29
Sorry, i had used some other class name actually.

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Post your class again, exactly as it is.

I get no output at all...

No error either ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

When I ran it (with the class named to something else), I get "b c" as the output.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

So did I.
Death Arte
Greenhorn

Joined: Feb 17, 2011
Posts: 21

Sir Christophe Verré is correct.. Try is a reserved word.

i try this..

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Sanjana Sharma wrote:Sorry, i had used some other class name actually.

Please PostRealCode next time.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sanjana Sharma
Greenhorn

Joined: Jan 08, 2011
Posts: 29

this is the class i used. Now , when i complied and ran this program on a friends system , i got the output as b c.

i tried running it on my system. I get this.. Screenshot of output attached.
i am confused now. How can i get the output in another system and not on mine??
Please refer to the attached file.



[Thumbnail for output.jpg]

Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

You likely used different arguments at your friend's computer.

Try changing the 1 in your for loop to 0. Java arrays are 0-based.
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

when you say
there is only one command line arg.
But when you say
there are 3

now have a look at your code to understand why its not printing in your machine.
Sanjana Sharma
Greenhorn

Joined: Jan 08, 2011
Posts: 29
Prem Sir, you just hit the target !
i found the answer .

thanks a bunch everyone .
i love this place
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Sanjana Sharma wrote:Prem Sir, you just hit the target !
i found the answer .

thanks a bunch everyone .
i love this place


Taking your question 1 step further. How do i enter a string with spaces in it as one string and not separate strings ? For example : welcome to java is 1 string and not 3. It is followed by rahul bose which is another string. ie args contains only 2 strings.

SCJP 6. Learning more now.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Surround your argument in double quotes in the command prompt.
 
Don't get me started about those stupid light bulbs.
 
subject: command line invocation