• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reg Class Path

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I could not get the rules regarding the class path. I placed the file helloworld.java in D:\java and I was able to compile and run helloworld from D:\java with out setting class path (the class path environment variable is empty). How can this be possible?
I have read that java.exe will not search the current folder by default for the class files. How ever, if I over ride the class path at run time by specifying java -cp MyJar.jar, it gives NoClassDefFoundError and I had to run the file by including . in the class path ie, java -cp MyJar.jar;. helloworld (I ran it from D:\java)
am I missing any thing here?

regards
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default(not -cp), the classpath is ".".
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default, javac searches the current folder for files. Hence, you were able to compile it without any classpath being set.
 
reply
    Bookmark Topic Watch Topic
  • New Topic