943,978 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1560
  • Java RSS
Jul 3rd, 2009
0

exception in thread main java .lang.NoClassDefFoundError:Abc

Expand Post »
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);
}
}
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
manveet is offline Offline
1 posts
since Jun 2009
Jul 3rd, 2009
0

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?
Reputation Points: 22
Solved Threads: 13
Junior Poster in Training
di2daer is offline Offline
66 posts
since Sep 2008
Jul 3rd, 2009
0

Re: exception in thread main java .lang.NoClassDefFoundError:Abc

Go to where the ".class" file is and type the command as java -cp . Abc
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Jul 3rd, 2009
1

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.
Last edited by adatapost; Jul 3rd, 2009 at 8:18 am.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 3rd, 2009
0

Re: exception in thread main java .lang.NoClassDefFoundError:Abc

whops, thank you for pointing that out
Reputation Points: 22
Solved Threads: 13
Junior Poster in Training
di2daer is offline Offline
66 posts
since Sep 2008
Jul 3rd, 2009
0

Re: exception in thread main java .lang.NoClassDefFoundError:Abc

Click to Expand / Collapse  Quote originally posted by di2daer ...
whops, thank you for pointing that out
You are welcome.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Frame and Multiple Panel ..Need Help
Next Thread in Java Forum Timeline: Read class from another class





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC