• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

CLASSPATH for System Classes

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a basic question about CLASSPATH. I read and understood that when I write my own Java files I need to set CLASSPATH Environment variable in order to locate the specific file by the JAVA Class Loader. But my question is that I have a JAVA file in which I am importing

Statement# 1Import java.util.*;
Statement# 2 Import myOwnPackage.*;

// Have some Source



When I want to compile this File I need to set the Class Path for the statement#2 to tell the class loader where the Package and where the Class File. This can be done in the System Environmental variable or at compile time by -CLASSPATH option. Up to here I am very well understood. When I compile this Java Source file by giving Class path for the Statement#2 (With out giving the class path for java.util ) I am able to compile and run successfully. But my question is that why I am not required to give or set the CLASSPATH for java.util ? Is this because this is system class ? Even if it is system class how can Class Loader is able to locate this ?
In my system I do not have any CLASSPATH for the java.util. I have Installed the JAVA in C:\Program Files\Java\j2sdk1.4.2_03.


I know this is a basic question but I am not able to understand this. I appreciate for the reply on this.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Java in General (Beginner)
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JVM internally maintains a location to the system classes; thus, you do not have to specify them in the classpath. (In older versions of Java, you did have to; however, this produced problems when running with the -cp version, so they essentially "hard linked" those classes.) The default ClassLoader knows how to load those classes by default, so you don't have to do anything.
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the clarification.
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic