This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java lang NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java lang NoClassDefFoundError" Watch "java lang NoClassDefFoundError" New topic
Author

java lang NoClassDefFoundError

Mahesh Malviya
Ranch Hand

Joined: Aug 20, 2004
Posts: 39
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

Joined: Dec 29, 2004
Posts: 1071
Is it saved in a file called Test.java?

case makes a difference. Test is not the same as test.
Mahesh Malviya
Ranch Hand

Joined: Aug 20, 2004
Posts: 39
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

Joined: Dec 14, 2004
Posts: 464
You could check to see if your classpath includes .(dot) the current directory.


ph34r my 133t j4v4 h4><0r1ng sk177z
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi,
I think you should point your classpath to your java class directory.

Hope this helps...

thanks
daniel
Mahesh Malviya
Ranch Hand

Joined: Aug 20, 2004
Posts: 39
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

Joined: Dec 06, 2001
Posts: 3061
You are more likely to get answers to this part of your question if you mosey on over to the JDBC forum.

Layne


Java API Documentation
The Java Tutorial
 
Consider Paul's rocket mass heater.
 
subject: java lang NoClassDefFoundError
 
Similar Threads
Post Increment test
return statement in finally and checked Exception
Determine logical pattern for loop
Multiple 'public static void main()'s
Calling another class