Database Reference
In-Depth Information
java -cp “.;C:\Program Files\java\ojdbc6.jar” mypkg.MyApp
In this example, we alert java.exe that the CLASSPATH parameter ( -cp ) is provided. The quotation
marks are required, because there is a space in the directory name Program Files. Note that forward
slashes would also work in this context.
Java Code and Syntax Concepts
I'm going to give a brief example of Java code. It is 20 lines long and not too complex, but it will
introduce you to many Java syntax concepts. You do not need to memorize the details of these
concepts—they will present themselves in every program you write in Java.
Throughout the following discussion, we are going to consider some aspects of the code in Listing 3-
3. Keep a bookmark at this page for reference as you read the next few sections.
Listing 3-3. MyApp2.java
package pkg2;
import oracle.sql.ARRAY;
import mypkg.MyRef;
public class MyApp2 {
private ARRAY myArray = null;
static MyRef myRef;
public static void main( String[] args ) {
MyApp2 m = new MyApp2();
MyRef useRef = new MyRef();
m.setRef( useRef );
ARRAY mA = m.getArray();
myRef = new MyRef();
}
public ARRAY getArray() {
return myArray;
}
void setRef( MyRef useRef ) {
myRef = useRef;
}
}
Note Find this code in the file named javadev/pkg2/MyApp2.java
Continuing our previous discussions about Java syntax, we see that this new code, MyApp2.java , is
in a new package (directory), pkg2 . For that reason, we have to import (refer to) the MyRef code in our
original package. Recall that both of those packages need to be found from some starting point in your
CLASSPATH in order to compile and run this code.
 
Search WWH ::




Custom Search