...

NoClassDefFoundError

jeepzy3
02-03-2003, 08:30 PM
I have this really easy piece of code which I can't seem to run. This code was cut n pasted.

The compile was fine, but when I run I get:
Exception in thread "main" java.lang.NoClassDefFoundError: DBTest

//code begin
import java.sql.*;
import java.io.*;

public class DBTest {
/**************************************
* You MUST change the url user and password
* to reflect your configuration
*/

String url = "jdbc:oracle:thin:@xxxxxxxx:1521:xxxxxxx";
String user = "xxxx";
String password = "xxxxxxxx";

public DBTest() {
}

public void getVersion () {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection (url,user, password);
DatabaseMetaData meta = con.getMetaData();
System.out.println("Database Product Name:" +
meta.getDatabaseProductName());
System.out.println("Database Product Version:" +
meta.getDatabaseProductVersion());
System.out.println("JDBC Driver Name:" +
meta.getDriverName());
System.out.println("JDBC Driver Version:" +
meta.getDriverVersion());
System.out.println("JDBC Driver Major Version:" +
meta.getDriverMajorVersion());
System.out.println("JDBC Driver Minor Version:" +
meta.getDriverMinorVersion());
con.close();
}
catch (Exception e) {
e.printStackTrace();
}

}
public static void main(String[] args) {
DBTest app = new DBTest();
app.getVersion();
}

}
//code end

When I am running the command to run, I am in the same directory as where DBTest.class is located.

If I specify the full path to the DBTest.class, I get the same error.

bcarl314
02-04-2003, 11:15 AM
Have you tried putting the code in a package? Some j2ee stuff requires that.

Just a thought.

jeepzy3
02-05-2003, 04:33 AM
Thanks. I had the code in a package and didn't realize it. That's why it compiled correctly but didn't run. When I commented out the package, it ran as expected.

King_of_Earth
04-21-2006, 02:06 AM
I have the same problem. What do you mean in a package?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum