DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   exception in thread main java .lang.NoClassDefFoundError:Abc (http://www.daniweb.com/forums/thread201408.html)

manveet Jul 3rd, 2009 4:00 am
exception in thread main java .lang.NoClassDefFoundError:Abc
 
import java.io.*;
class Abc
{
public static void main(String arg[])
{
try{
File f= new File("c:/xyz.txt");
FileOutputStream fout=new FileOutputStream(f);
byte data[]={65,66,67,68};
fout.write(data);
fout.close();}
catch(Exception e)
{
System.out.println(e);
}
}
}

di2daer Jul 3rd, 2009 4:07 am
Re: exception in thread main java .lang.NoClassDefFoundError:Abc
 
You're missing an import statement for FileOutputStream, other than that, I can't spot any errors with this code. I think you'll have to explain a bit more about when you get this error. In what context are you using it?

masijade Jul 3rd, 2009 4:08 am
Re: exception in thread main java .lang.NoClassDefFoundError:Abc
 
Go to where the ".class" file is and type the command as java -cp . Abc

adatapost Jul 3rd, 2009 8:18 am
Re: exception in thread main java .lang.NoClassDefFoundError:Abc
 
A mistake by di2daer.

You're missing an import statement for FileOutputStream.

When we use java.io.*; It means any class/interface of java.io package can be used in our program file without qualify it with java.io package name.

di2daer Jul 3rd, 2009 8:47 am
Re: exception in thread main java .lang.NoClassDefFoundError:Abc
 
whops, thank you for pointing that out :)

adatapost Jul 3rd, 2009 8:51 am
Re: exception in thread main java .lang.NoClassDefFoundError:Abc
 
Quote:

Originally Posted by di2daer (Post 907393)
whops, thank you for pointing that out :)

You are welcome.


All times are GMT -4. The time now is 1:41 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC