• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
  • Frits Walraven
  • Carey Brown
  • Jj Roberts


Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 = "jdbc:oracle: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

Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Geeta Ravikanti
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic