problem with getCodeBase()
I have a problem with the deployment of a 'jarred' applet. Here's my directory structure (in a web module);
applets
myjar.jar
data.txt
webpages
mypage.jsp
myjar.jar contains an applet.
mypage.jsp has an applet tag that includes this line:
archive="../applets/myjar.jar
This works fine. The problem comes when the applet tries to download data from data.txt. I'm using getCodeBase(), which should return the URL of the applets directory. But getCodeBase() is returning the URL of the webpages directory. In other words, it's behaving like getDocumentBase()!
Why is this happening? What's the solution? Any help greatly appreciated!
miguel
Very good point Ron. I found it out by myself in the meantime: getCodeBase() uses the CODEBASE attribute in the APPLET tag. This info was hard to find!
Anyway u get your 5 dukedollars!
The thing is ... my applet is still not working. When in my IDE (Forte), everything is fine, but online, the class cannot be found. This is not a getCodeBase() problem anymore, but probably a classpath problem. I tried putting the applet jar in WEB-INF/lib/, but it didn't work either.
Here's my original applet tag:
<applet align="middle" archive="../livemaps/lm_applet_jet.jar" code="applet.Applet1.class" codebase="../livemaps/" height="50" width="60">
The dir structure is exactly the same but it won't work online!!! Any suggestions?
miguel
Thanks for the duke $$$ :)
I know just what your going through too. I have an applet that works fine if I launch it through the appletviewer, but if I bring the html page up in IE, I get a ClassNotFoundException. AND it's not even my class!!! It's one of the system classes (java.util.Random). Talk about weird. So I need to get that fixed before I can offer any more suggestions. And who knows, maybe our two problems are related ?!?
rSully at 2007-6-29 12:42:54 >

OK, I figured out my problem. I'm trying to use 1.3 stuff while still using the old Applet tag instead of the new Object tag. Duh! You're not, um, trying to do the same thing are ya?
rSully at 2007-6-29 12:42:54 >

Ok, please explain what you mean by "...my applet is still not working..." and "..the class cannot be found." Do you mean, the applet doesn't work because it's not be found, or...? If this is the case, then your right, you have some kind of classpath problem going on. So, for a quick troubleshooting test, why don't you humor me, and put your .jsp file in the same directory as your applet .jar and see if it will run when they're all lumped together.
-Ron
P.S. How can you resist those tempting v1.3 classes? :)
rSully at 2007-6-29 12:42:54 >

Hey Ron, my ordeal is through. What I had were 3 bugs on top of each other!
- my computer at home made package names UPPERCASE
- the applet was in an INCLUDED jsp, so I needed to update the including JSP to force recompilation.
- there was 1 hardcoded '/' in my code instead of File.separator, fatal cause I develop in WIndows and deploy in Solaris.
Well, I learned a few things the hard way this week.
mig