Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Unable to load applet in web browser.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am new to Java. I wrote a very simple applet. It works fine with the Eclipse browser. When I tried to load it on to web browser, classDefNotFound exception arises.
Here is my code for the applet:
MyApplet.java

Here is my html file:
DrawOval.html

My Project hierarchy is like this.
FirstApplet/src/com/example/applet/DrawOval.html .
My class file goes into: FirstApplet/bin/com/example/applet/MyApplet.class
DrawOval.html is also in the same directory after I build my project.
I tried using relative path in the CODEBASE to the applet class. It didnt work either. Please help me find the reason.
 
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's generally easiest to keep the class files in the same directory as the HTML file. That's also how it needs to be here, given the APPLET tag you have.
 
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code attribute of an applet element requires the fully qualified class name of the class. That would be com.example.applet.MyApplet Furthermore, whether it is stored in a Jar or as a loose class on the server, it needs to be in a directory structure that reflects that package structure. As a loose class, with no codebase specified, the class would need to be located at com/example/applet/MyApplet.class, where the com directory is in the same directory as the HTML.
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic