• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

java lang NoClassDefFoundError

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The following code compiles well but gives error when run as java Test.
I am a beginer please help me.

public class Test{
public static void main(String[] arg){
System.out.println("HI");
}
}
Exception in thread "main" java.lang.NoClassDefFoundError: Test

Mahesh
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it saved in a file called Test.java?

case makes a difference. Test is not the same as test.
 
Mahesh Malviya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am giving the right name. class name is Test and I am running it using java Test. What could be the reason.

Mahesh...
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could check to see if your classpath includes .(dot) the current directory.
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think you should point your classpath to your java class directory.

Hope this helps...

thanks
daniel
 
Mahesh Malviya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks. I got the solution. I was actually establishing the connection. For that I was setting classpath to import the oracle.jdbc.driver.*. Then It gets the package but for not considering the current package it was giving the classNotFoundError. Actually for testing purpose I made one more class which contains only "Hi". That could also not run as I had changed the classpath. Now I am ok with this.
but for establishing connection I am getting the error as

Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))

can you please help me further.
my class is

import oracle.jdbc.*;
public class Connect {
private static Connection conn = null;
public static Connection getConnection(){
try{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc racle:thin:@pmserver:1521:ubocpm","scott","tiger");
return conn;
}catch(SQLException se){
System.out.println(se.getMessage());
return null;
}
}
public static void main(String[] arg){
getConnection();
System.out.println(conn);
}
}

Mahesh...
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are more likely to get answers to this part of your question if you mosey on over to the JDBC forum.

Layne
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic