This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confusion in running the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confusion in running the program" Watch "confusion in running the program" New topic
Author

confusion in running the program

yogi maheshnath
Ranch Hand

Joined: Jan 07, 2008
Posts: 30
Hi,

when i am running the following code on command line,i am getting Exception in thread"main"java.lang.NoClassDefFoundError emosql.But,when i am running this code on IDE there is no error.Please explain.
---------------------------------------------------------------------------
import java.sql.*;
public class demosql
{
Connection con;
ResultSet rs;
Statement st;
demosql()
{

try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mydsn");
st=con.createStatement();
rs=st.executeQuery("select name from emp");
while(rs.next())
{
String str=rs.getString(1);
System.out.println(str);
}
}
catch(Exception e)
{}

}
public static void main(String args[])
{
new demosql();
}
}
-------------------------------------------------------


Thanks&Regards<br />Yogi MaheshNath
Ram Prasad
Greenhorn

Joined: Feb 02, 2008
Posts: 9
hi

When you are running through the command prompt you should make sure the classes which you are referring are there in classpath. in you case it is demosql class file

When you run in IDE, IDE takes care of it by mentioning the classpath as a parameter while executing the program using java -d option available

Ram Prasad
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: confusion in running the program
 
Similar Threads
Its about Connection.close()
confusion in running the program
why Invalide cursor state exception
why Invalide cursor state exception
what is cause of this exception?