jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic


Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Hi All,
My program is

package org.common;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MyUtility {
public static Connection getConnection(){
Connection conn = null;
String url = "jdbcracle:thin:@localhost:1521/";
String dbName = "xe";
String driver = "oracle.jdbc.driver.OracleDriver";
String userName = "SYSTEM";
String password = "remora";
try {
conn = DriverManager.getConnection(url+dbName,userName,password);
}catch(Exception ex){
return conn;
public static void closeConnection(Connection con){
try {
} catch (SQLException e) {

after exectuion of the above program i am gettign the following errors

Exception in thread "main" java.lang.NoClassDefFoundError: MyUtility (wrong name
: org/common/MyUtility)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

i set the calss path for ojdbc14.jar in appropriate path
Can any one tell me where did i mistaked

Laxmikant Ruikar

Joined: Nov 29, 2005
Posts: 23
As per you error stack trace, you are not giving fully resolved name of your MyUtlilty class while compiling the code.

Or check path from where are you compiling code.

Specify your command to compile code.

Rajah Nagur
Ranch Hand

Joined: Nov 06, 2002
Posts: 239
Something wrong with your PATH & CLASSPATH settings.

It seems that might have duplicate copies of MyUtility class, Delete or clean your system of duplicate copies of MyUtility class.

You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Finance\WEB-
lasses\org\common>javac MyUtility.java

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Finance\WEB-INF\c
lasses\org\common>java MyUtility

I am getting the error while running the appliation

I executed the program liket this

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Finance\WEB-INF\c
lasses\org\common>set CLASSPATH=ojdbc14.jar;.

Is there any wrong thing i did
plaese tell me the way of path getting right solution
I agree. Here's the link: http://aspose.com/file-tools
subject: NoClassDefFoundError
It's not a secret anymore!