This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
For starters, the code attribute takes a class name, not a file name. Class names contain dots, whereas file names contains slashes.
The codebase attribute should contain the root of the class directory hierarchy - that means it should not contain the package name. Also, does the "src" directory really contain class files? That sounds counter-intuitive.
Thanks for the reply.I was wrong about "src" directory.I am still unable to get the applet.If I understand you clearly then the code attribute should contain only class name even if it is in a pakage?like code="MyApplet.class"
also if the correct directory is "AppletTest\build\classes\pk1"where pk1 is the package name then codebase="/AppletTest/build/classes/" right? Still cant find the applet.So far I am only able to get the applet only when I make a jar file which is in the same directory as the jsp file by archile="somename.jar". Its kind of eating me why can't I do it with the code base .Some more help would be really appreciated.
Joined: Mar 22, 2005
What is the layout of your files and directories? What is the error you get in the Java Console?
Joined: Jun 16, 2013
Well, I get class not found exception.And,here is the layout of my flies:
AppletTest(Web dynamic project).There I have the package"pk1"which contrains the appletcode"MyApplet.Java"
"WebContent" folder contains the jsp file which contains the the code fragment I paste above.
Thanks once again
Joined: Mar 22, 2005
Where the source file is is irrelevant - it's not used at runtime. Important is where the class file(s) is.
What HTML does get created by that JSP tag? Also, post the entire stack trace.
To make things easy you may wish to start out simple - don't use codebase, and instead keep the files in the same directory - meaning, the "pk1" directory should be in the same place as the JSP file.
Also, are you accessing the JSP directly? It gets more complicated if you hide it behind a servlet, because then the URL has no resemblance to the directory structure.
Lastly, try relative paths in the JSP tag. I'm not sure if absolute paths are supposed to work.