Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Peculiar behaviour of java XXXXX *

 
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?
 
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.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic