Database Reference
In-Depth Information
JAR File Directory Separator
A Java Archive (JAR) file (like the ojdbc6.jar file that we downloaded previously) is a compressed
directory tree with compiled Java files and other files for use as a set. You can, and later we will, create a
JAR file with the JAR utility in the JDK. You can look at the contents of a JAR file with any ZIP utility.
In a JAR file, you would find a directory tree. For example, inside the ojdbc6.jar file you would see
these directories (and many others):
/oracle
/oracle/sql
In the /oracle/sql directory, you would see files like ARRAY.class . The ARRAY.class file is a compiled
Java file.
Do not be disturbed by my use of the / (slash) for a directory separator character. This is the
standard separator character for UNIX, and it is the default for Java. Java will understand slash, but the
standard Microsoft backslash must be escaped (explained) to Java, in most situations. The backslash
serves another purpose in Java as the escape character itself, so an escaped backslash looks like this \\.
The following two filenames are equivalent in Java on a Windows box, but I will always use the first style.
"C:/Program Files/Internet Explorer/SIGNUP/install.ins"
"C:\\Program Files\\Internet Explorer\\SIGNUP\\install.ins”
Java Packages
We don't have the Java code of the Oracle JDBC drivers, but we can deduce that the code of the ARRAY
class (mentioned previously) was in a file named ARRAY.java . And in that file was a package statement:
package oracle.sql;
Notice how the package name correlates with the directory tree, using a dot (.) separator character
for the package, instead of a slash for the directory. At Oracle, the corporate developers keep the file
ARRAY.java in a directory named sql, which is in a directory named oracle . They compile the class in a
matching directory tree. And they create the JAR file by collecting all the compiled content, starting with
the oracle directory.
You need to keep this fundamental concept in mind: packages equal directory paths. Packages also
provide security and affect how we reference Java code and how we compile and run it, as we shall see.
Development at Command Prompt
I have coached many developers, new and experienced, who have primarily accomplished their Java
development efforts or education with an IDE. When I ask them to do any troubleshooting or test their
application from the command prompt, often they don't know where to begin. I believe you need to be
prepared to execute (run) Java from the command prompt, and we will be doing some of that here.
Environment
When you get to the command prompt and you want to compile or run your code, you will need a
couple of operating system environment settings: your PATH to find the JDK executables, and your
CLASSPATH to find your code and the Oracle JDBC code. From wherever the recent JDK executables exist,
they are able to find their own libraries of code (Java can find Java libraries, although it hasn't always
been that way), so you don't have to specify them in the CLASSPATH .
 
Search WWH ::




Custom Search