HP OpenVMS Systems

ask the wizard
Content starts here

Java CLASSPATH Handling?

» close window

The Question is:

Java Question:
  I am trying to use the following code to connect to Jturbos jdbc driver for
 MS SQL Server. Works fine on Unix,NT,MAC and compiles fine on OpenVMS but I
 get Classnotfound error on
   Class.forName ("com.ashna.jturbo.driver.Driver");
my CLASSPATH is set fine and my directory structure looks like
Where I execute JAVA CLASS:
Executing command
 java "stest"
  it seem as though the JM is having problems qualifying the qualified path.
Any Suggestions would be appreciated.
import java.sql.*;
 * Test retreiving values back using scrollable updatable resultSet.
public class stest
   static public void main(String args[])
      throws java.lang.ClassNotFoundException, Exception
       Connection cx = null;
       Statement stmt;
       ResultSet rs;
      try {
            String      url      = "jdbc:JTurbo://pch329:1433/Product
            String      user     = "xxx";
            String      password = "xxx";
            cx      = java.sql.DriverManager.getConnection(url, user, password);
            stmt = cx.createStatement();
	      rs = stmt.executeQuery("SELECT * from test;");
	      System.out.println("Got results:");
	      while(rs.next()) {
		 String str = rs.getString(1);
        catch(Exception e) {

The Answer is :

  Here is an example of working with classpaths:
$ java -version
java version "1.2.2-1"
Classic VM (build J2SDK.v.1.2.2-1:07/29/2000-02:00, native threads, jit_122)
$ ty HelloWorld.java
public class HelloWorld {
        public static void main(String[] args) {
        System.out.println ("Hello Java!");
$ javac HelloWorld.java
$ java "HelloWorld
Hello Java!
$ jar -cvf h.jar "HelloWorld.class
added manifest
adding: HelloWorld.class(in = 425) (out= 291)(deflated 31%)
$ del HelloWorld.class.*
$ java "HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
$ java -classpath h.jar "HelloWorld
Hello Java!
$ sh log classpath
%SHOW-S-NOTRAN, no translation for logical name CLASSPATH
$ def/user classpath h.jar
$ java "HelloWorld
Hello Java!
$ sh log java$classpath
%SHOW-S-NOTRAN, no translation for logical name JAVA$CLASSPATH
$ def/user java$classpath h.jar
$ java "HelloWorld
Hello Java!

answer written or last revised on ( 24-OCT-2000 )

» close window