wood burning stoves 2.0*
The moose likes Applets and the fly likes Class Not Found Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Class Not Found Error" Watch "Class Not Found Error" New topic
Author

Class Not Found Error

kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
Hi.
I am using first time Applet, as test Applet it was working fine.
But When I Run Actual Applet File with my Application Structure It is giving ClassNot Found Error.
-The Applet Class is in the package "com.sp.utility" i.e , rootfolder/WEB-INF/classes/com/sp/utility/
-My Applet class file Name is DescWin.class
-My HTML file which is calling Applet is in
rootfolder/main/ShowApplet.html

So Please Tell me how my APPLET Tag should be in HTML file so that it can Solve my Error
Please Help Me out
Thank You
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Nothing that is inside of WEB-INF will ever be served to to a client. You need to move all files (.class and .jar) that relate to the applet into a publicly accessible directory. It's easiest to put those into the same directory as the HTML file containing the applet tag.


Ping & DNS - my free Android networking tools app
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
Thank You For Your Reply Sir,
I can not Move the Applet class file because it depends some more classes and in one of my file my database connectivity is also present so instead of moving my Applet class file , Can i include the path in APPLET Tag, how can i do that please tell me
Thank You
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
That's not possible. All files used by the applet must be publicly accessible, because otherwise the browser JRE can not load them.

That's one of the reasons why using JDBC in an applet is a security risk (which I assume you mean by "database connectivity").
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
If i am not Wrong WEB-INF/classes is publicly accessible so i kept my applet class with other clasess in that.
What else can be done instead of moving so that Applet class is accessible form the package com.sp.utility itself ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
If i am not Wrong WEB-INF/classes is publicly accessible

It's not.
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
Thank You for correcting me. I was in wrong Thinking thank you once again.
Suppose that if i move my Applet classes to main folder where my Html page is located which is calling Applet then, How can i include or import other classes which are in com.sp.utility package simply by import command in my applet file or anything else i have to do?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
If that's a hierarchy of loose class files then you can just put them in that directory as well, and the JRE will find them. But you really should package your class files in a jar file - it's much faster to load. Any jar files you have need to be listed in the archive attribute of the applet tag. See http://java.sun.com/docs/books/tutorial/deployment/applet/html.html for details.
kirtesh jain
Ranch Hand

Joined: Nov 15, 2008
Posts: 44
all my classes and the servlet classes i kept in the package com.sp.utility, and since my apllet is using some java classes from those so i kept that also in that. By default when we deploy all class files are generated in the WEB-INF/classes folder then again i have to build the necessory files with the Applet file ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
You don't have to build it again, you just have to copy the required files there. I'd put the code into various packages, maybe 1) servlets and related classes, 2) applet and related classes, 3) shared utility classes. That makes it easier to copy the right files to the right directories.

You need to be very careful only to copy the necessary files to the applet directory, and nothing else, especially no servlet classes. All class files that are publicly accessible can be decompiled, and then give away valuable information.
 
 
subject: Class Not Found Error