This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java lang NoClassDefFoundError

 
Mahesh Malviya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could check to see if your classpath includes .(dot) the current directory.
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic