• 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

How does Java APIs become available for use ?

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JDK1.6 is installed on computer.
When I create a new Java class, I can import a package as "import java.io.*;"
How does compiler find this java.io.* ? If I want a custom class to be available for use, then I need to set the path for that class in classpath variable. For java.io.*, there is no classpath set. I checked Path variable and its set for java.exe file. So how and where is the path for these APIs set ?

Thanks
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are included with the Java installation, and the compiler knows where they are.
 
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They line inside a file called rt.jar (I think) and the compiler is programmed to look there.
 
jignesh soni
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

They are included with the Java installation, and the compiler knows where they are.

I understand that they are included with java installation, but how do compiler finds these classes ? How is classpath set for these packages ? Can I see them in environment variables ? If not, then how is classpath set ?

They line inside a file called rt.jar (I think) and the compiler is programmed to look there

So, is rt.jar set in some classpath ? When compiler starts looking for some classes it will look in environment variables. So is this rt.jar set in any environment variable ? If compiler does not find classpath in environment variables, does it look for anywhere else ? If no, then how is rt.jar set to be made available to compiler ?

Thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not part of the classpath, the compiler simply knows where it should be in a JRE installation, like Bear and Campbell said. Try removing the file and see what happens :-)
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jignesh soni wrote:I understand that they are included with java installation, but how do compiler finds these classes ?


How classes are found
 
jignesh soni
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the link.

I was reading that link.

Note that the classes which implement the Java 2 SDK tools are in a separate archive from the bootstrap classes

what is meant by Java 2 SDK tools ? Is tools something different from classes ?
Please give some examples of SDK tools. I may be using it, but I am not aware they are called SDK tools

In general, you only have to specify the location of user classes. Bootstrap classes and extension classes are found "automatically".

What about core java classes. It does not say anything about core java classes and packages. Are core java classes known as extension classes ? If not, then how are these classes found ?

Thanks
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jignesh soni wrote:

In general, you only have to specify the location of user classes. Bootstrap classes and extension classes are found "automatically".

What about core java classes. It does not say anything about core java classes and packages. Are core java classes known as extension classes ? If not, then how are these classes found ?


As you have already been told, the core Java classes are in rt.jar

Bootstrap classes - Classes that comprise the Java platform, including the classes in rt.jar and several other important jar files.

 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jignesh soni wrote:what is meant by Java 2 SDK tools ? Is tools something different from classes ?
Please give some examples of SDK tools.


JDK Tools and Utilities
reply
    Bookmark Topic Watch Topic
  • New Topic