Results 1 to 3 of 3
  1. #1
    menzow is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

    Default First signed applet, doesn't even run :\

    Hey!

    I am just trying out signing applets, and even a simple java script won't run after signing it :\

    It does run from the command line, but when I try to load it into my browser, it just doesn't work.

    JavaCode:
    Java Code:
    import java.applet.Applet;
    public class Secure_Connection extends Applet{
      public static void main(String[] args){
        System.out.println("hi");
    	System.exit(0);
      }
    }
    html:
    Java Code:
    <APPLET 
      CODE = "Secure_Connection.class"
      WIDTH="10" HEIGHT="10"
      ARCHIVE = "Secure_Connection.jar"
      >
    This example uses an applet.
    </APPLET>
    When I check the console, it doesn't print anything.
    Though, when I run it from the command prompt using:

    Java Code:
    java -jar Secure_Connection.jar
    It prints "hi" perfectly fine.

    I compile and sign my applet using the following batch code:
    Java Code:
    javac *.java
    jar cfm Secure_Connection.jar MANIFEST.txt Secure_Connection.class
    keytool -genkey -alias me -keystore compstore.ks -keypass test1234 -dname "cn=jones" -storepass test1234
    jarsigner -keystore compstore.ks -storepass test1234 -keypass test1234 Secure_Connection.jar me
    Please tell me what I am doing wrong.

  2. #2
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default

    An applet doesn't call the "main" function by startup, but it calls the "init" or the constructor.

    An applet does NOT show the "System.out.println" commands if you run it in an browser, that's why you have to use the applet's automatically called function "paint" for displaying text.

    Use this as applet:
    Java Code:
    import java.applet.Applet;
    public class Secure_Connection extends Applet{
     public void init()
     {
     }
    
     public void paint(java.awt.Graphics g)
     {
      g.drawString("hi", 10, 10); // (your_text, x-coordinate-on-applet, y-coordinate-on-applet)
     }
    }
    Then you can jar it and sign it on the same way you did.

    Then it is runnable in your browser.

    (you can run your applet in the appletviewer with cmd, with the following command:
    Java Code:
    appletviewer [your_applet_html]
    Last edited by Dennis; 02-21-2011 at 10:37 AM.

  3. #3
    menzow is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Dennis View Post
    An applet doesn't call the "main" function by startup, but it calls the "init" or the constructor.

    An applet does NOT show the "System.out.println" commands if you run it in an browser, that's why you have to use the applet's automatically called function "paint" for displaying text.

    Use this as applet:
    Java Code:
    import java.applet.Applet;
    public class Secure_Connection extends Applet{
     public void init()
     {
     }
    
     public void paint(java.awt.Graphics g)
     {
      g.drawString("hi", 10, 10); // (your_text, x-coordinate-on-applet, y-coordinate-on-applet)
     }
    }
    Then you can jar it and sign it on the same way you did.

    Then it is runnable in your browser.

    (you can run your applet in the appletviewer with cmd, with the following command:
    Java Code:
    appletviewer [your_applet_html]
    Woooow !!!
    Thanks allot man, never noticed that was the problem :O

    Thank you so much haha

Similar Threads

  1. Signed applet security warning
    By danzik17 in forum Java Applets
    Replies: 0
    Last Post: 01-24-2011, 10:54 PM
  2. File Input - Signed JAR Applet
    By treckstar in forum Java Applets
    Replies: 2
    Last Post: 01-13-2010, 04:36 AM
  3. [SOLVED] signed applet, or what
    By AXH in forum Java Applets
    Replies: 2
    Last Post: 10-10-2008, 02:28 AM
  4. Signed applet works only with jre 1.6u10 beta...
    By smartizzz in forum Java Applets
    Replies: 0
    Last Post: 08-07-2008, 08:54 AM
  5. run java signed applet in vista
    By nanaji in forum Java Applets
    Replies: 7
    Last Post: 05-14-2008, 12:59 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
  •