Results 1 to 15 of 15
  1. #1
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    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:
    Java Code:
    mzw3.com/Control/Signed/
    Here is the class:
    Java 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:
    Java 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!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Are there any messages in the browser's java console?
    Copy and paste them here.

  3. #3
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    Error:
    Java 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

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Looks like the jvm is looking for a class: VNC.class
    instead of the class VNC.
    Leave the .class off the code= attribute.

  5. #5
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    Same error:

    Java 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:
    Java Code:
    Caused by: java.io.IOException: open HTTP connection failed.
    Last edited by Master Zero; 09-06-2008 at 03:56 AM.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    What are the contents of the VNC.jar file? The VNC.class file should be at the root level.

    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 :
    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:
    504B 0304 14 00
    Last edited by Norm; 09-06-2008 at 04:09 PM.

  7. #7
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    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?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    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.
    it works fine as a regular class(once uploaded)
    What does that mean?
    You originally said:
    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 06:30 PM.

  9. #9
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    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.
    Java 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 06:56 PM.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    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?

  11. #11
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    I am using GoDaddy to host my file. I’ll do some research and see if it does support it.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Try renaming your VNC.jar file to VNC.zip and change your html to use it: archive=VNC.zip.

  13. #13
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    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.

  14. #14
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    Quote 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-06-2008 at 11:00 PM.

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    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

Similar Threads

  1. Replies: 0
    Last Post: 03-31-2008, 04:35 PM
  2. Load URL that contains spaces?
    By barkster in forum Java Applets
    Replies: 0
    Last Post: 01-30-2008, 09:40 PM
  3. how to load a lot of files?
    By gabriel in forum Java Servlet
    Replies: 1
    Last Post: 08-07-2007, 06:04 PM
  4. Help with load image
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 07:16 AM
  5. load a document to the server
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-29-2007, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •