Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

Applet Newbe Q

Thread view: 
polilop - 19 Jun 2005 15:29 GMT
I have an applet (other applets on the net work fine)
on my pc, in the same directory i have the class file and thehtml file. when
i start my applet in the browser it tourns out grey and the console
writes out this:

Error loading class: GeomApplet
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: GeomApplet
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.securedClassLoad
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run

I know that it cannot find the class file but i cannot find what i have to
do so it finds it. In my HTML file i put
<APPLET  CODE="GeomApplet.class"  WIDTH="353" HEIGHT="207"  ></APPLET>

Allso tried with codebase showing the path to the class file and still
dosent work Any Idea?
Andrew Thompson - 19 Jun 2005 15:38 GMT
> I have an applet ..
..
> java.lang.NoClassDefFoundError
> java.lang.ClassNotFoundException: GeomApplet
> at com/ms/...

The problem is that you are using Internet Explorer..
<http://www.physci.org/codes/javafaq.jsp#appletie>

HTH

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

polilop - 19 Jun 2005 23:14 GMT
Ok. I've done all that is needed and now i get this error
java.lang.NoClassDefFoundError: GeomApplet (wrong name: anApplet/GeomApplet)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
basic: Exception: java.lang.NoClassDefFoundError: GeomApplet (wrong name:
anApplet/GeomApplet)

And my class is in the "anApplet"  Folder?
polilop - 19 Jun 2005 23:15 GMT
Forgot, and the name is GeomApplet.class.

> Ok. I've done all that is needed and now i get this error
> java.lang.NoClassDefFoundError: GeomApplet (wrong name:
[quoted text clipped - 16 lines]
>
> And my class is in the "anApplet"  Folder?
Andrew Thompson - 19 Jun 2005 23:42 GMT
> Forgot, and the name is GeomApplet.class.

Forgot.. to do the best thing and supply an URL. *

That way I could clear up  this little confusion as
to what is the name of your class/package and what the
applet element says, because that seems to have changed
between the first and second posts.

BTW - Is your applet in a package?

* Give us an URL where we can see your applet break
(at GeoCities or wherever) link to the from the applet
page to the exact code you are using.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

polilop - 19 Jun 2005 23:55 GMT
I am testing it localy.
my HTM lookes like this
<HTML>

<BODY>

<APPLET CODE="GeomApplet.class" WIDTH="353" HEIGHT="207" >Your browser is
not Java enabled.

</APPLET>

</BODY>

</HTML>

My applet is in a package and looks like this

package anApplet;
import java.applet.*;
import java.awt.Graphics;
public class GeomApplet extends Applet {

public void paint (Graphics g)
 {
  double a=2;
  double b=3;

  Kvadrat Kv=new Kvadrat();//a class in the same package
  Krug Kr = new Krug();// a class in the same package
  Kv.setStr(a);
  Kr.setR(b);
  g.drawString("Povrsina kvadrata je " +Kv.povrsina(),10,50);

  }
}

All classes and the HTM page ar ina a folder(package) called anApplet
Andrew Thompson - 20 Jun 2005 00:25 GMT
> I am testing it localy.

You can be testing it locally, but debugging it on
the web.  It is much easier for everybody else that
is *helping* you.

> my HTM lookes like this
> <HTML>
>
> <BODY>
>
> <APPLET CODE="GeomApplet.class"

CODE="anApplet.GeomApplet.class"

>...WIDTH="353" HEIGHT="207" >Your browser is
> not Java enabled.
...
> My applet is in a package

..because your applet is in a package, you need to
put it in a directory the same name as the package.

...
>   Kvadrat Kv=new Kvadrat();//a class in the same package
>   Krug Kr = new Krug();// a class in the same package

These classes also need to uploaded to the same package directory.
Applets that reside in packages and have multiple classes are much
more reliable and easier to administer if you jar them into a
single file.

> All classes and the HTM page ar ina a folder(package) called anApplet

..No!  put the .html in the directory *above* 'anApplet'
package and it should find the class OK.

BTW - this is an applet that can be made to run
on the MSVM theat you were using earlier, but
that is more advanced.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

polilop - 20 Jun 2005 00:38 GMT
I've placed my HTML outside the package and still errors then noticed that
in my HTML i wrote
CODE="anApplet/GeomApplet.class"

and my console thinks that GeomApplet is another
folder and in that folder is searching for a class.class file
so i just wrote
CODE="anApplet/GeomApplet" and now works fine

tried to put the HTML back into the package and it dosent work just as you
said.
Thx alot for the help.

By the way you mentioned a post before that MSVM is more advanced? is that
mean its better then JVM or that the code to write in for the MSVM is more
advanced (for this case)?
Andrew Thompson - 20 Jun 2005 00:55 GMT
> By the way you mentioned a post before that MSVM is more advanced?

No way I said that.  (Ever!)

The MSVM (Java 1.1) is about 10 years old and cannot do
lots of things that modern JVM's can do.  But there is nothing
in your code that was not in Java 1.1 - so your applet could
run on anything *from* the ancient MSVM, up to the latest
1.5 Java.

If your code can also work in Java 1.1, it makes sense
to ensure it *does* work in 1.1 VM's.  That is what I meant.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.