• Post Reply Bookmark Topic Watch Topic
  • New Topic

How does Java APIs become available for use ?  RSS feed

 
jignesh soni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are included with the Java installation, and the compiler knows where they are.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • 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: 150
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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 :-)
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • 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: 150
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!