Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
NoClassDefFound Error while running an applet Posted by Tanushri on 15 Dec 2009 at 6:26 AM
HI,

I downloaded the project named MouseEventDemo Project from the link:
http://java.sun.com/docs/books/tutorial/uiswing/examples/events/index.html#MouseMotionEventDemo

And pasted the events folder from extracted content to my bin folder where my javac.exe is present.

Now the compilation of java files present in it , is successful but i get an error when i try to execute by an html file, say BlankArea.html to execute BlankArea.java.The contents of file are:


<applet code="BlankArea.class" codebase = "." height="200" width="300">

</applet>



I am attaching the events folder.
Please guide me.

Thanks,
Tanushri.





Report
Re: NoClassDefFound Error while running an applet Posted by Andre897 on 18 Dec 2009 at 7:05 PM
Hi,i think that you might not be too far from the solution to your little problem.Now yes you compiled the code and it complied without any fuss but the code is located in a folder in your bin folder,so at your applet tag attributes i.e <applet></applet>,try and specify where the code is if it isn't visibly found in the same folder where you have stored your html files.so try this

<applet class = "BlankArea.class" codebase ="location of BlankArea java code which the class file is been used" width="" height=""></applet>

I designed a html file that contains an applet and my applet was in a different folder called classes.i had to specify where the java code could be located since it is in a different folder IN the same folder where my html files are.Consider it,trying to import a package in java.

I hope this helps you in solving it

Report
Re: NoClassDefFound Error while running an applet Posted by Andre897 on 18 Dec 2009 at 7:05 PM
Hi,i think that you might not be too far from the solution to your little problem.Now yes you compiled the code and it complied without any fuss but the code is located in a folder in your bin folder,so at your applet tag attributes i.e <applet></applet>,try and specify where the code is if it isn't visibly found in the same folder where you have stored your html files.so try this

<applet class = "BlankArea.class" codebase ="location of BlankArea java code which the class file is been used" width="" height=""></applet>

I designed a html file that contains an applet and my applet was in a different folder called classes.i had to specify where the java code could be located since it is in a different folder IN the same folder where my html files are.Consider it,trying to import a package in java.

I hope this helps you in solving it

Report
Re: NoClassDefFound Error while running an applet Posted by Tanushri on 21 Dec 2009 at 2:29 AM
HI,

I have my Html file and class file in the same folder.
Also i have tried executing with the codebase ="."
Please suggest me some other solution.

Thanks,
Tanushri.
Report
Re: NoClassDefFound Error while running an applet Posted by Andre897 on 22 Dec 2009 at 9:33 PM
Hi again.successful compilation of a java code doesn't guarrantee a successful run,so i suggest you try to first run the applet by using the appletViewer,say appletViewer Beans.html in your command line on your cmd after compilatiion.

This will display the applet in html format.if it displays,then your code will have to be carefully looked into but if it doesn't,dont use the applet anymore because there might be some classes and methods used that are in packages created and used only by them(where you downloaded it from).Besides it is advisable to design your own applets than to download due to this problems.

if you still have the same problem,kindly send me a copy of your code so that i can see what i can do.my email address is condrezon1@yahoo.co.uk.And another thing,did you place a dot(.) as the codebase value in your applet attributes,because you wrote that you tried executing with the codebase =".".if you did,remove the dot(.) and
try running the html file again because the dot(.) is kinda telling the browser that the classfile is located somewhere and since it cant locate it,it throws such exception which you are currently getting.

Does it solve your problem?.if it didn't, mail your code to me using the stated email add.
Report
Re: NoClassDefFound Error while running an applet Posted by Andre897 on 22 Dec 2009 at 9:35 PM
Hi again.successful compilation of a java code doesn't guarrantee a successful run,so i suggest you try to first run the applet by using the appletViewer,say appletViewer Beans.html in your command line on your cmd after compilatiion.

This will display the applet in html format.if it displays,then your code will have to be carefully looked into but if it doesn't,dont use the applet anymore because there might be some classes and methods used that are in packages created and used only by them(where you downloaded it from).Besides it is advisable to design your own applets than to download due to this problems.

if you still have the same problem,kindly send me a copy of your code so that i can see what i can do.my email address is condrezon1@yahoo.co.uk.And another thing,did you place a dot(.) as the codebase value in your applet attributes,because you wrote that you tried executing with the codebase =".".if you did,remove the dot(.) and
try running the html file again because the dot(.) is kinda telling the browser that the classfile is located somewhere and since it cant locate it,it throws such exception which you are currently getting.

Does it solve your problem?.if it didn't, mail your code to me using the stated email add.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.