DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Java Applet in another directory (http://www.daniweb.com/forums/thread164216.html)

BobTheFish Dec 26th, 2008 4:06 am
Java Applet in another directory
 
My applet runs fine when it's in the same directory as the html, but when I put it in another directory, Java console says it can't find the file.
When I copy-paste into my browser the address I'm specifying for 'code' in my applet tag, it finds the file without problems.

Thanks.

stephen84s Dec 26th, 2008 5:07 am
Re: Java Applet in another directory
 
Paste the code of the HTML file which is using your Applet, So we can see whats going on.

BobTheFish Dec 26th, 2008 5:33 am
Re: Java Applet in another directory
 
This works fine:
<applet width=450 height=300 code="applet_maxr.class">

This doesn't:
<applet width=450 height=300 code="http://.../applet_maxr.class">

stephen84s Dec 27th, 2008 5:10 am
Re: Java Applet in another directory
 
Sorry for the delayed reply, but I would like to point out that the "code" attribute of the "<applet>" tag can only take a relative URL and not an absolute one.

To be able to use the applet mentioned in the URL, you will need to use the "codebase" attribute of the "<applet>" tag, shown below:-

<applet width=450 height=300 codebase="http://.../" code="applet_maxr.class">

You can learn more about them here.

BobTheFish Dec 27th, 2008 7:06 pm
Re: Java Applet in another directory
 
Thanks!


All times are GMT -4. The time now is 7:45 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC