Two Laptop Bag*
The moose likes Beginning Java and the fly likes Packages and Import statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Packages and Import statements" Watch "Packages and Import statements" New topic
Author

Packages and Import statements

Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
I'm a little confused about where the class library files are kept and how to access them and their documentation. I�m looking at a .java file that has the following import statement (?and package declaration?):

package deqstpr;

import java.sql.*;

code is here�

I don�t have any problems finding the java.sql documentation in the API specification on Sun�s website. My problem with looking at documentation is with the deqstpr package.

I would also like to understand where these files are kept on my computer, or in this case on a database server (I think).

As with all of my posts, please point out ALL of my misconceptions (even if it�s not my direct question), thank you.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

There's no guarantee that there's documentation anywhere for any given Java class. Sun is careful to document everything and publish the documentation in well-known locations, but Joe Developer may not be.

All the package names that start with java or javax are from Sun and are documented in the JDK and on Sun's web site. Anything else (with the exceptions of some org.xml packages, and a few others) come from someplace else, and you have to consult the individual vendor for documentation.


[Jess in Action][AskingGoodQuestions]
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
Thanks for the reply.

It's a little more comforting to know that there may not be any documentation with this code versus me just not knowing how to find it - although the latter may still be the case :\.

However, I'm still confused about two things from my post:

1) Where are these packages or libraries located?

2) What is the difference between the statements �package deqstpr;�, and �import java.sql.*;�? <==I don't think I actually asked this question in the original post.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Sun's libraries -- the ones that come with the JDK itself -- are in *.jar files in the JDK distribution. Most them are in j2dskXXX/jre/lib/rt.jar . Other libraries are wherever they've been installed. There's an environment variable named CLASSPATH that's used to tell Java about places where libraries may be installed on your local system.

If you're looking at a "package" statement, then you're looking at source code. A library will be compiled from that source code, but the source isn't the library itself.

A "package" statement tells the Java compiler that the contents of a file should be put into the given package. An "import" statement tells the compiler about other packages that this file references.
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
Thank you, thank you, thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packages and Import statements