This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Peculiar behaviour of java XXXXX *

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
giving
java xxxx *
at the command prompt

class xxxx
{
public static void main(String a[])
{
for(int i=0;i<a.length;i++)
{
System.out.println("xxxx " + i + ":" + a[i]);
}
}
}
lists out all the files and dirs inthe current directory? why does this happen what exactly happens?
 
Jaap van Hengstum
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This behaviour is because the Unix commandline has automatic wildcard expansion, which expands any given wildcard on the commandline to its matching filenames before turning control to the program.
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but this also happens on the windows system. what do u say about this?
 
Jaap van Hengstum
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My wrong... it seems that java is doing its own wildcard expansion (at least on Windows systems), by the way you can disable this by quoting the commandline argument, like:

myprogram "*"
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ernest,
Where are u man? I have been waiting for ur answer. After seeing many answers to the questions which i have posed i have been a great fan of you.
I thought you would help me out. kinldy look into the question and i am sure you will give me a correct answer and I am not flattering.
thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic