Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-05-2008, 10:08 PM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default [SOLVED] JAR applet won’t load.
Hello,

I recently sign an Applet after archiving it with the Eclipse’s IDE and it worked fine when loading it from a local HTML file on the hard drive. But when I upload it to the web server, it can’t fine the Class file.

Here is the link:
Code:
mzw3.com/Control/Signed/
Here is the class:
Code:
import javax.swing.*;
import java.applet.Applet;


public class VNC extends Applet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void init() {
		JOptionPane.showMessageDialog(null, "Hello, World!");
	}
}
HTML Code:
Code:
<applet code="VNC.class" archive="VNC.jar" width="100%" height="100%"></applet>
Both the HTML and JAR file are in the same directory. Any help will be greatly appreciated!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 09-06-2008, 01:24 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Are there any messages in the browser's java console?
Copy and paste them here.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-06-2008, 02:50 AM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
Error:
Code:
load: class VNC.class not found.
java.lang.ClassNotFoundException: VNC.class
	at sun.applet.AppletClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadCode(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.plugin.AppletViewer.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
	at sun.applet.AppletClassLoader.getBytes(Unknown Source)
	at sun.applet.AppletClassLoader.access$100(Unknown Source)
	at sun.applet.AppletClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 10 more
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-06-2008, 04:02 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Looks like the jvm is looking for a class: VNC.class
instead of the class VNC.
Leave the .class off the code= attribute.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-06-2008, 04:38 AM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
Same error:

Code:
load: class VNC not found.
java.lang.ClassNotFoundException: VNC
	at sun.applet.AppletClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadCode(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.plugin.AppletViewer.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
	at sun.applet.AppletClassLoader.getBytes(Unknown Source)
	at sun.applet.AppletClassLoader.access$100(Unknown Source)
	at sun.applet.AppletClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 10 more
How do you turn your class into a JAR file? Maybe I am doing something wrong. And what about this part:
Code:
Caused by: java.io.IOException: open HTTP connection failed.

Last edited by Master Zero; 09-06-2008 at 04:56 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-06-2008, 03:28 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
What are the contents of the VNC.jar file? The VNC.class file should be at the root level.

Quote:
open HTTP connection failed.
That looks like the reason the class file was not read. I don't know why you would get that.

I tried your site and get the same error.
The html that is loaded is missing the beginning parts. It starts with the <APPLET tag. It ends with an https URL reference.
Try making a complete/correct HTML page with all the body, head and ending tags.

I think there is a problem getting your jar file from the server. When I tried to read it, I get the following. The first part below is in HEX, below that is in text :
Quote:
504B 0304 14 3C2F6F626A6563743E....
PK...</object></layer></span></div></table></body></html><!-- adsok -->..<script language='javascript' src='https://a12.alphagodaddy.com/hosting_ads/gd01.js'></script>..
If you open a jar file in a hex editor the first few bytes are as follows:
Quote:
504B 0304 14 00

Last edited by Norm; 09-06-2008 at 05:09 PM.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 09-06-2008, 05:54 PM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
Ok, I renamed VNC.jar to VNC.zip to look at the contents inside. They are as follow:

VNC.zip (jar):
- META-INF (folder)
- VNC.class

META-INF
- MANIFEST.MF
- MZW3.RSA
- MZW3.SF

I renamed it back to .jar and made sure it still worked by double clicking it and I got the "hello, world!" message box.

I redesigned the html file to include every HTML tag there should be for a normal document. What troubles me is that it works fine as a regular class (once uploaded). So it possible that it is not even looking inside the jar file for the class?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 09-06-2008, 07:03 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Did you try reading the jar file on the server and looking at the contents of what you get? I'm sure the jar file on your disk is OK if the applet is loaded from it using local html file.
Quote:
it works fine as a regular class(once uploaded)
What does that mean?
You originally said:
Quote:
But when I upload it to the web server, it can’t fine the Class file.
Is that no longer true now? Does it now "fine the Class file"?
Does that mean the problem is only when the class file is in a jar file?

Are you able to download the jar file from the server? Does your server support downloading jar files?

Last edited by Norm; 09-06-2008 at 07:30 PM.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 09-06-2008, 07:49 PM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
No, I tried uploading just the VNC.class to see if it would work and it did, so I uploaded the jar which of course did not work, it seems that the jar file is not being acknowledged, thus the browser may not be looking inside the jar for the class (I could be wrong).

So yes, there is a problem when the class is inside the jar.

Ok, I don’t know how to check the contents of a jar file on the server so I downloaded it back to my hard drive, and it still does load in a local HTML.

I have zip up both the class and jar in case you may want to look at it yourself, and try it out.
Code:
mzw3.com/Control/Signed/VNC.zip
Thank you for your help and patients thus far.

Last edited by Master Zero; 09-06-2008 at 07:56 PM.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 09-06-2008, 09:41 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
I used this URL to load your jar file from the server:
http://mzw3.com/Control/Signed/VNC.jar

When I used the above in my browser and saved the jar to a local file, its contents were as I described above.

Does your server support downloading jar files via HTML <applet tags?
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 09-06-2008, 11:20 PM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
I am using GoDaddy to host my file. I’ll do some research and see if it does support it.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 09-06-2008, 11:40 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Try renaming your VNC.jar file to VNC.zip and change your html to use it: archive=VNC.zip.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 09-06-2008, 11:49 PM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
Ok so I spoke to a representative and he told me that I can’t do it on a shared hosting account. So I guessed that solved the problem. Would you by any chance know of a good hosting company that I can check out? Godaddy’s dedicated servers are quite expensive.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 09-06-2008, 11:55 PM
Member
 
Join Date: May 2008
Posts: 26
Rep Power: 0
Master Zero is on a distinguished road
Default
Originally Posted by Norm View Post
Try renaming your VNC.jar file to VNC.zip and change your html to use it: archive=VNC.zip.
OMG, you’re a genius! It works!

Thank you so much man!

Note: Sorry man, but they won’t let me add to your reputation points. I owe you one!

Last edited by Master Zero; 09-07-2008 at 12:00 AM.
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 09-07-2008, 12:10 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
google has free space for simple files, but doesn't allow making folders so everything is in the same folder. It does allow HTML to use jar files. For example: This page loads an applet that tries to read a file from your C: drive. Its signed and causes a prompt asking for permission.
Applet Reader
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Security Applet will not load under a specific user. MartyF Java Applets 0 03-31-2008 05:35 PM
Load URL that contains spaces? barkster Java Applets 0 01-30-2008 10:40 PM
how to load a lot of files? gabriel Java Servlet 1 08-07-2007 07:04 PM
Help with load image trill New To Java 1 08-01-2007 08:16 AM
load a document to the server Heather JavaServer Pages (JSP) and JSTL 2 06-29-2007 03:08 PM


All times are GMT +2. The time now is 12:20 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org