This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

NoClassDefFoundError

 
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 {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
}catch(Exception ex){
ex.printStackTrace();
}
return conn;
}
public static void closeConnection(Connection con){
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}



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
4)
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

Regards
Geeta
 
Greenhorn
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.


LDR
 
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-
INF\c
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
 
ice is for people that are not already cool. Chill with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!