This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

* as a parameter to main

 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why, but notice "dir *" works in command prompt.
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Val Pecaoco
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sayed Ibrahim Hashimi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a link?
 
B K Sahu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the link...but it gives no explination.
http://www.javafaq.nu/java/500/index.shtml?hop=jspecialis.javafaq
 
Kasey Tritt
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 411
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1817
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this previous thread on this topic.
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure that soon SUN guys will close this bug by saying it is not a bug but operating system problem.
 
Val Pecaoco
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is JRE 1.4 or Win2000 bug. Please visit Sun's Java bug database
Jamal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic