wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes * as a parameter to main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "* as a parameter to main" Watch "* as a parameter to main" New topic
Author

* as a parameter to main

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2579

Run this code -

When run from command prompt as - java TestDir *,
This code simply lists all the files from current directory. How is it working?
TIA,
- Manish
luco zhao
Ranch Hand

Joined: Apr 23, 2002
Posts: 50
I don't know why, but notice "dir *" works in command prompt.


Great thanks,<br />Luco Zhao
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2579

I agree that * works as a wildcard charactter while listing directories, but why should it work as such in Java VM?
I expected output to be - Arg 0 : *
But don't know why it is working this way.
TIA,
- Manish
Steven Sun
Greenhorn

Joined: Apr 29, 2002
Posts: 26
Originally posted by luco zhao:
I don't know why, but notice "dir *" works in command prompt.

Nod,i think so ,too.
i think windows commond will treat * as all files in current directory,and pass them to the java process


newly SCJP2 <img src="tongue.gif" border="0">
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Hi guys,
Quite novel, isn't it?
The answer is in JavaFAQ (just open your eyes widdddeeee and you'll find it ).
Ex Animo Java!
-- Val


"Knowledge is power, but enthusiasm is the key." -- Lavern Barn
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
Do you have a link?


SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
B K Sahu
Greenhorn

Joined: May 17, 2002
Posts: 1
I was looking for the TestDir Class in www.javafaq.nu .. Didnt find it do you have a direct link ?
Thanx.
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
I found the link...but it gives no explination.
http://www.javafaq.nu/java/500/index.shtml?hop=jspecialis.javafaq
Kasey Tritt
Greenhorn

Joined: May 02, 2002
Posts: 15
I found the link...but it gives no explination.
http://www.javafaq.nu/java/500/index.shtml?hop=jspecialis.javafaq

The above link does not tell us anything about the question we had but Alexandre Patchine, the owner of the link just want to sell us his book.
Sorry, Alexandre Patchine, This is a self help group - we help each other in Java. I may not know the answer, I will find out through other resources and I can live without knowing the answer for now.
[ May 22, 2002: Message edited by: Kasey Tritt ]
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
By the way,
java -classpath . TestDir *.html
will print .html files in current directory:-)
this parameters also works : a*.java,abc.*a,...
I'll find the reason !!!
Jamal
www.j-think.com
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
This is a bug.
http://developer.java.sun.com/developer/bugParade/bugs/4672990.html
Jamal Hasanov
www.j-think.com
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
This is a bug.
http://developer.java.sun.com/developer/bugParade/bugs/4672990.html
You must use
java TestDir "*"
Jamal Hasanov
www.j-think.com
Kasey Tritt
Greenhorn

Joined: May 02, 2002
Posts: 15

I find it interesting that people can actually try to sell something based on a bug. I mean, if I purchase the book based on the info on the link, I'll be mad to find out that the reason for the question is a bug .
Thanks Jamal for the info.
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1751
    
    2
Check out this previous thread on this topic.
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
I am sure that soon SUN guys will close this bug by saying it is not a bug but operating system problem.


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Originally posted by Jamal Hasanov:
This is a bug.
You must use
java TestDir "*"


Mine worked fine with just java TestDir *.
My JDK is 1.3.1 on Win 98.
Ex Animo Java!
-- Val
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
This is JRE 1.4 or Win2000 bug. Please visit Sun's Java bug database
Jamal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: * as a parameter to main