I've built a simple applet under JBuilder as follows;
package fetcher;
import javax.awt.*;
import javax.swing.*;
etc.
public class Fetcher extends JApplet {
etc. etc.
It all runs fine when executed via an HTML page within the JBuilder
project/package directory, but I'm damned if I can deploy it to my local
IIS. I know this should be a simple matter of putting the .html and .class
files in an appropriate directory structure under C:\Inetpub\wwwroot\ , but
I've tried every damned permutation I can think of and still can't get it to
work. I've tried following the guidelines on this Borland tutorial site but
still no joy;
This is the directory structure I have, which as far as I can tell is
exactly as the tutorial says;
C:\Inetpub\wwwroot\Fetcher\Fetcher.html
C:\Inetpub\wwwroot\Fetcher\fetcher\Fetcher.class (& Fetcher$FetchL.class)
The Fetcher.html file contains the following;
<html><body>
<APPLET
CODEBASE="\Fetcher\"
CODE = "fetcher.Fetcher.class"
NAME = "Fetcher"
WIDTH = 500
HEIGHT = 300
HSPACE = 0
VSPACE = 0
ALIGN = middle
>
</APPLET>
</body></html>
When I try to access the web page using the URL
http://localhost/Fetcher/Fetcher.html I get the following Java console
error;
load: class fetcher.Fetcher.class not found.
java.lang.ClassNotFoundException: fetcher.Fetcher.class
I know I'll be kicking myself, but I'd be very grateful if someone could
tell me where I'm going wrong.
Cheers
--
Steven Smith
I've been trawling through the various technical forums and see that this is
actually a common problem using java 2 applets via the Java plugin with IE,
though I've yet to see a definitive solution.
I'm using IE 6.0.2800 (XP Pro), Java JRE & Plug-in version 1.4.1_03, which I
believe is the latest. I have the plug in configured to use the browser
proxy settings (I have no proxy), though I've tried it both ways without
success.
The applet runs fine when invoked from a file://.. URL (provided I remove
the codebase tag), but not when I try to run it through the local IIS as
http://localhost/Fetcher/Fetcher.html.
I'm not sure how much more there is to play with.
If someone could just confirm that the HTML I'm using is correct
(particularly the codebase tag), that would be a start.
<html>
<head>
<title>Fetcher Java Applet Demo</title>
<body>
<applet
CODEBASE="/Fetcher/"
CODE = "Fetcher.class"
WIDTH = 500
HEIGHT = 300
HSPACE = 0
VSPACE = 0
ALIGN = middle
alt="Your browser understands the <APPLET> tag but isn't running the
applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
>
</applet>
</body>
</html>
The complete error message is as follows;
Java(TM) Plug-in: Version 1.4.1_03
Using JRE version 1.4.1_02 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Steven Smith
Proxy Configuration: No proxy
[snip]
load: class Fetcher.class not found.
java.lang.ClassNotFoundException: Fetcher.class
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:153)
at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:506)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:536)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:252)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:42)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:143)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:140)
... 10 more
You don't need the codebase attribute in this case. Using
your example, (same folder layout), I can access the
applet using this URL:
http://localhost/Fetcher/Fetcher.html
where Fletcher.html contains this applet tag:
<applet code='fetcher.Fetcher'
width='300'
height='300'>
</applet>
or with this one:
<applet code='fetcher.Fetcher'
codebase='/Fetcher/'
width='300'
height='300'>
</applet>
--Steve
Thanks for the reply, but as it turns it was nothing to do with the applet
or html.
I was using Windows Authentication rather than anonymous access on my local
web site (I generally just use it for local development & experimentation
and never normally publish the results).
For some reason IIS and/or the Java plug-in won't allow the applet to load
under windows authentication but will under anonymous access. Windows
security has always been something of a black art for me and it's not
immediately apparent to me why things should work this way, but it seems to
be sorted now.
> For some reason IIS and/or the Java plug-in won't allow the applet to load
> under windows authentication but will under anonymous access. Windows
> security has always been something of a black art for me and it's not
> immediately apparent to me why things should work this way, but it seems to
> be sorted now.
Sun Java's URLConnection stuff didn't understand NTLM authentication
until 1.4.2 - try using that.
You are a gentleman and a scholar, sir.
Replaced 1.4.1_03 with 1.4.2 JRE and now it all works fine under Windows
Authentication. You get a little NTLM username and password dialog the first
time you access the web page, and then you're away.
Thanks very much for the tip.