4 Replies Latest reply: Aug 11, 2011 10:22 AM by AndersonPereira RSS

    Error complie "Exception in thread "main" java.lang.NoClassDefFoundError"

    AndersonPereira
      Dear All,

      I have the following problem can not compile the code below.
      Here my settings and the code.

      Thanks for the help.

      My java version.
      ===============================================
      D:\bea\jdk150_22\bin>java -version
      java version "1.5.0_22"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode)
      ===============================================

      I use a bat to compile the code
      ===============================================
      set JDK_HOME=D:\bea\jdk150_22
      set PATH=%JDK_HOME%\bin;%PATH%
      set CLASSPATH=%CLASSPATH%;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar

      rem ---- compile
      javac GetDBOracle.java

      rem ---- testing
      java GetDBOracle

      rem ---- add to jar
      jar cf GetDBOracle.jar GetDBOracle.class
      ===============================================

      My java code

      ===============================================
      import java.sql.*;
      import java.io.*;

      public class GetDBOracle {
      public static String GetDBOracle(String Parm1, String Parm2) throws SQLException
      {     
      String myResult = "";     
      // Load Oracle driver
      DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
      // Connect to the local database
      Connection conn = DriverManager.getConnection
      ("jdbc:oracle:thin:@localhost:ORCL", "ORC", "ORC2010");     
      // Query the employee names
      Statement stmt = conn.createStatement ();
      ResultSet rset = stmt.executeQuery ("SELECT JAVA_GET_VALUE('"Parm1"','"Parm2"') FROM DUAL");
      // Print the name out
      while (rset.next ()) {
      myResult = rset.getString (1);
      }
      //close the result set, statement, and the connection
      rset.close();
      stmt.close();
      conn.close();     
      return myResult;
      }
      public static void main(String args[])
      {
      try {
      System.out.println(GetDBOracle("XXI", "12000"));
      } catch (Exception e) {
      System.out.println(e.getMessage());
      }
      }
      }
      ===============================================

      Erro
      ===============================================
      Exception in thread "main" java.lang.NoClassDefFoundError: GetDBOracle
      ===============================================