Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Packages and Import statements

 
Chris Staten
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chris Staten
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, thank you, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic