开发者

java applet won't work

开发者 https://www.devze.com 2022-12-29 20:41 出处:网络
this is homework stuff, but the question is not much about coding. the task is to write a java applet to work on an m-grid server. i have the server running on apache. it has a few sample applets in .

this is homework stuff, but the question is not much about coding. the task is to write a java applet to work on an m-grid server. i have the server running on apache. it has a few sample applets in .jar and .class form. the .class versions work; the .jar versions work on appletviewer, but they break if I submit them as a job to the server with this:

load: class examples/pixelcount/PixelCount.class not found.
java.lang.ClassNotFoundException: examples.pixelcount.PixelCount.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: examples.pixelcount.PixelCount.class

I'm not really sure where exactly is the problem in here, given that they work on appletviewer. any help would be appreciated..

ED开发者_Go百科IT:

don't know if I wrote it clearly. by ".class version" i refer to html file with this content:

<applet height="300" width="450" code="examples/pixelcount/PixelCount.class"></applet>

and ".jar" with this content:

<applet height="300" width="450" archive="PixelCount.jar" code="examples.pixelcount.PixelCount.class"></applet>

EDIT2:

the mentioned example jar file can be found here


It can't find the file PixelCount.class, its not in the directory examples/pixlecount that's why this error is happening.


The PixelCount class is not packaged in your jar I think.

And as the error is Caused by: java.net.ConnectException: Connection refused: connect it might be that it tried to obtain that class from the net somewhere, and the location does not match or a proxy is in between.

EDIT

You do have the archive someplace the m-server, whatever that may be, can find it? See the Java Applet Tag ref. docs. You may need something like

CODEBASE = codebaseURL
This OPTIONAL attribute specifies the base URL of the applet--the directory 
that contains the applet's code. If this attribute is not specified, then the 
document's URL is used.

The CODE is relative to the base URL of the document which holds the applet tag. If you want to override that you might need that CODEBASE parameter.


Don't include the .class extension in the code attribute.

examples.pixelcount.PixelCount is the name of the class.
examples.pixelcount.PixelCount.class is the name of the file that contains the class.

The code attribute should read

code="examples.pixelcount.PixelCount"
0

精彩评论

暂无评论...
验证码 换一张
取 消