Applet Method Signed?

Hello,
I'm relativly new to the applet world so sorry if my question looks stupid.
I'm currently working on a Java applet that performs a screencapture and save it to the client file system.
To be able to capture the screen and write it , i had to sign the Applet.
It is what i did using : Keytool and Jarsigner tools.
So on my test applet , in the Init() method , i perform my screencapture and save it. It works well if the applet is signed , if not i have security exception that is normal.
Then i tried to move my code to another method. I removed it from the Init() and create a new method i named CaptureScreen() . And i copied my previous code in that method.
In my HTML Test page, i have embedded the applet using <APPLET> tag and add a HTML button that triggers a javascript that calls my method.
MyApplet.Capture();
My problem :
When i call this method on the signed applet i got a security exception.
java.security.AccessControlException: access denied (java.awt.AWTPermission createRobot)
If the same code is called in the Applet's Init'() method i don't have it.
So i guess i have to sign the Capture() method too. But how to do that? How to sign a specific method?
Thanks a lot in advance for your help
Youki

Hi
You don't sign methods. You sign the whole .jar file. So if you signed the file again after the adding the captureScreen() method, the applet .jar file should be OK.
Not sure but I guess the problem occurs because the calling script is not signed.
See http://java.sun.com/j2se/1.3/docs/guide/plugin/security.html
(I can't find the same information in newer plugin developer guides though.)

Similar Messages

  • I have a basic applet method timing problem with Firefox (and Chrome), not IE nor Opera. Works if JavaScript issues windows.alert() prior, fails otherwise.

    I have an applet method, which is invoked from a JavaScript function, that is triggered by the window.onload event. The problem seems to center in the loading of the applet and its methods.
    If I step through the 3 applet acceptance prompts (I chose to use a down-level Java), the applet method is never invoked, nor is an exception raised. How this happens is beyond my understanding.
    As additional information, the Init(), start(), and "desired" Java methods all use the synchronized keyword. This is an attempt to minimize the exposure to a multi-thread environment.
    If I issue a message from JavaScript (via window.alert()) PRIOR to invoking the method, I can get the desired results in special circumstances:
    1) When the alert is presented, Firefox also prompts, SIMULTANEOUSLY, to block/continue the applet (the first of the 3 applet acceptance prompts). I can accept that these are separate threads.
    2a) If I walk through the 3 applet acceptance prompts FIRST, and then hit the OK button on the alert message SECOND, I get the desired results, my applet method executes, and all is well (other than the fact that I would prefer not to have the alert in place at all).
    2b) If I hit the OK button on the alert message FIRST, and then walk through the 3 applet acceptance prompts SECOND, I get the same results as when the page loads WITHOUT the alert, which is the applet method is never invoked, nor is an exception raised. Weird, huh?
    The above problem only occurs when the browser and the applet's URL are loaded for the first time.
    Subsequent invocations (after the page & applet has been loaded initially) do not have the failing symptoms.
    It is my understanding that IE and Firefox (and Chrome and Opera, for that matter) each use the same implementation of JavaScript provided by Microsoft. Please correct me if this information is inaccurate.
    The failing page and it's applet are proprietary; I cannot provide the Internet URL, nor the Java or JavaScript source, to aid in your analysis.

    I can speak to the source code, but have no access to it.
    The current process/thread that invokes an applet method must check to see that the applet is not currently being loaded by another process/thread. If it is being loaded, the current process/thread should block until the load is complete, THEN attempt to invoke the applet method.
    Please forward my concern to a knowledgable developer. The nature of the problem, once identified, can be addressed in a very straightforward manner.

  • How to get the applet method value in javascript variable

    Hi,
    I have an applet which reading the text file content, text file has valued either ON or OFF
    import java.applet.*;
    import java.io.*;
    public class A extends Applet
    public String line="";
    public void init( )
    String strPath ="D:/WAS_Status.txt";
    try
                             BufferedReader objReader = new BufferedReader(new FileReader(strPath));
                             line = objReader.readLine();
    }catch( IOException e)
    e.printStackTrace();
                        System.out.println("val :"+line);
              public boolean returnFileValue()
                   if("ON".equals(line))
                        return true;
                   else
                        return false;
    In html file :
    <HTML>
    <HEAD>
    <SCRIPT language="JavaScript">
    var line='';
    function loadAppContent()
         line=document.TestApplet.returnFileValue();
         alert("val : "+line);
    </SCRIPT>
    </HEAD>
    <BODY onload="loadAppContent()">
    <APPLET CODE="A.class" NAME="TestApplet" >
    </APPLET >
    </BODY>
    </HTML>
    I am calling the applet method. But I am not able to get value either as true or false.
    line=document.TestApplet.returnFileValue();
    Getting error as object doesnt support this property.
    I tried, line=document.TestApplet.line;
    Gets val as undefined.
    The line variable of Applet will return either ON or OFF value.
    Pls suggest where it has gone wrong or is there any other way?

    Yes it is a reserved word to warn that this applet , lets say send messages to the HTML page that call it.
    You will find the instruction how to do that at sun site.
    Yes you have to implement an interface inside the applet (code)
    and send a message to HTML with the name and parameters of
    the Javascript you want to call!
    But for all this to work you have to put in your project two new classes.
    And after that call some methods that does the job you want.
    Look for Java to JavaScript Comunication to get what you want!.
    check this per exemple!
    http://java.sun.com/products/plugin/1.2/docs/jsobject.html
    See You ( Ate mais )

  • Java Applet Certificate Signing Window comes up BLANK!

    Hi Everyone I have a problem where
    Java Applet Certificate Signing Window comes up BLANK!
    It comes up as blank gray panel with the java logo on the upper left.
    the title bar says "Java Plugin Security Warning"
    And I can't figure out what to do to make it come up properly. I tried double clicking it dragging it around to make it repaint itself nothing happens.
    I have tried clearing temp files deleting files from IE, deleting cookies, clearing the history.
    Now i'm going to restart the computer and see if it works.
    It is supposed to give me buttons.
    1. Accept for this session
    2. Grant
    3. Deny
    4. View Certificate
    But does anyone have any idea how to address this issue ?
    Stephen

    You might try setting the trace level to 5 in the plugin's Java console and looking what it spits out while the applet is launching. I remember seeing loads of information in there including stuff relating to certificate validation. It might be helpful.
    The trick to getting this info during start up:
    1) get the plugin to load by directing your browser to page with a known applet. Write your own little stub applet and load it or go to http://java.sun.com/. There's an applet on that page.
    2) bring up the plugin's console if it's not already and then go to a blank page.
    3) set the trace level to 5 in the console. (just press the 5 key).
    4) go to the page that launches your applet. You'll have tons of information pour out in your console.
    Happy hunting.

  • Call applet method with arguments from JavaScript

    I have an applet with a method doSomething(int a, String b, double c), I want get a,b,c from threee text fields put into an HTML page, and pass them to the applet method. I've a very poor knowledge in JavaScript, how can I pass correctly the arguments without raise a CastException? It seems to me that JavaScript doesn't have int, String, double.....

    Hi!
    You can verify before you send the parameters to the applet
    Something like that:
    var result = parseInt (a);
    if (result =NaN)
    alert("Sorry not Int");
    return false;
    and after that you can send the parammeters to the applet that way:
    document.yourApplet.Your_function_from_applet(result,..)
    hope this help!
    adina

  • Call applet methods from Javascript

    Hello,
    If I call applet method like :
    function callbackFunc(){
        var pp = appletID.getData();
        alert(pp);
    It works only if applet is deployed with <APPLET> tag or with javascript.
    If applet is deployed using <Object> and <embed> tags, in browser console the error is :
    TypeError: appletID.getData is not a function
    I couldn't find why is that behaviour. What do I do wrong?
    Thanks

    Hi Paul,
    (1)Seems to be your Java Runtime Environment path is still setted for JRE 1.3.0_01 and not for 1.3.1. So pelase go to the
    Control Panel-->java plugin 1.3.1-->Advanced. Here you set the Java Runtime Environment to the JRE 1.3.1 version. Its better to remove the older version before installing the new version on JRE.
    (2)<OBJECT> tag won't work for Netscape. You can only use <APPLET> or <EMBED> tag for Netscape.
    Hope this will help you.
    Anil
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Problem calling applet method using IE

    I've searched through the forum and can't seem to find anything that can help me fix this. I'm trying to call an applet's method using Javascript. This is working fine under Netscape, but not IE. Everything I've read seems to indicate that I'm doing this right, but I'm getting "Object doesn't support this property or method" when I try to call the applet method from IE.
    In this example method, I'm trying to call the applet's countChars method, which should return the length of the string you pass into it. Works under Netscape 6.2, but not IE 6.0
    Here's my applet code:
    import java.lang.String;
    public class test extends java.applet.Applet {
    public static int countChars(String s) {
    return s.length();
    And my HTML
    <HTML>
    <HEAD>
    <script language="Javascript">
    function refreshApplet()
    /*     i = document.forms.myForm.TestApplet.countChars();
         document.forms.myForm.output.value=i; */
         document.forms.myForm.output.value=document.applets["TestApplet"].countChars(document.forms.myForm.input.value);
    </script>
    </HEAD>
    <BODY>
    <APPLET CODE = "test.class" WIDTH = 400 HEIGHT = 400 ALIGN = middle NAME = "TestApplet" scriptable="true">
    </APPLET>
    <br>
    <form name="myForm">
    <input type="text" name="input">
    <input type="button" value="click me" onClick="refreshApplet();">
    <hr>
    <input type="text" name="output">
    </form>
    </BODY>
    </HTML>
    Thanks in advance!
    Craig Drabik
    Sr. Programmer/Analyst
    University at Buffalo

    I have very similar problem, my applet works OK using Netscape (6.2 and 7.0), but with IE 6.0 It only works with windows XP;
    The reported error is "Object doesn't support this property or method"
    Can someone please help me to solve this problem.
    Cheers
    Horus
    This is my code:
    - I call the applet using javaScript and input the method setData with two strings.
    function graphic()
         var dataZenith;
         var dataManual;
         initVariables();
         dataZenith = graphicZENith(); //Call other Javascript functions
         dataManual = graphicManual(); //Call other Javascript functions
         document.AppletOne.setData(dataZenith,dataManual);
    I run the applet with this HTML code:
    <applet NAME="AppletOne" code="Appl.class" width="450" height="450"
    MAYSCRIPT></applet>
    //Applet code/////////////
    import java.awt.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.util.*;
    public class Appl extends Applet {
         private int [] myArray1 = new int [156];     
         private int [] myArray2 = new int [156];
         private boolean flag = false;
         // maxDataYAxesNumber es usado para dividir el eje de las Y
    public void init()
              setFont(new Font("SansSerif", Font.BOLD, 12));
              setBackground (Color.white);
              setSize(getSize());     
    // Get data and put in an array
    public void setData(String data1, String data2)
              final String DELIMITER = ",";
              final StringTokenizer theTokens1 =
                   new StringTokenizer(data1, DELIMITER);     
              final StringTokenizer theTokens2 =
                   new StringTokenizer(data2, DELIMITER);
              try
                        String dataX = data1;
                        for (int i = 0; i < 156; i++)
                        myArray1[i] = Integer.parseInt(theTokens1.nextToken().trim());
                        myArray2[i] = Integer.parseInt(theTokens2.nextToken().trim());
              catch (NumberFormatException e) {};
              flag = true; //I get the data OK
              repaint();
    public void paint (Graphics g){
    Graphics2D g2d = (Graphics2D)g;
    setData(data1, data2) ;
    if (flag == true)
                   //Call other functions to process the graphic
    else g2d.drawString(" Sorry I can get Data", 100,80);          

  • Problem accessing applet methods since 1.4.2_06

    Hello,
    I'm working with ie 6.0
    I'm accessing applet methods from javascript
    My applets were working fine until I installed the JRE 1.4.2_06 (I tested them with JRE 1.4.2_05 and it worked)
    Now, when I call an applet method from javascript, I have a javascript exception, as if the applet is not loaded, but I think it is : I can see it in the traces in the java console !
    I didn't modify the code, just the JRE.
    It doesn't work with jre 1.5 too
    Here a simple sample code that doesn't work with JRE 1.4.2_06 :
    APPLET :
    import java.applet.Applet;
    public class Test extends Applet
         public void test() {
              System.err.println("test");
    HTML :
    <html>
    <body>
    <script language="JavaScript">
         function myTest() {
              document.myform.test.test();
    </script>
    <form name="myform">
    <OBJECT NAME="test" WIDTH=500 HEIGHT=120 CLASSID="CLSID:8AD9C840-044E-11d1-B3E9-00805F499D93">
    <PARAM NAME="code" value="Test.class">
    <PARAM NAME="scripting" value="true">
    </OBJECT>
         <input type="button" value="test !!" onclick="myTest()">
    </form>
    </body>
    </html>
    If you have any suggestion ...
    Thanks

    It should work, what if you try the following:
    html file:
    <html>
    <body>
    <script language="JavaScript">
    function myTest() {
    try{
         document.myform.test.test();
    }catch(e){
         alert(e.description);
    function myTest1() {
    try{
         document.getElementById("test").test();
    }catch(e){
         alert(e.description);
    </script>
    <form name="myform">
    <OBJECT NAME="test" id="test" WIDTH=500 HEIGHT=120 CLASSID="CLSID:8AD9C840-044E-11d1-B3E9-00805F499D93">
    <PARAM NAME="code" value="Test.class">
    <PARAM NAME="scripting" value="true">
    </OBJECT>
    <input type="button" value="test !!" onclick="myTest()"><br>
    <input type="button" value="test with getelementbyID!!" onclick="myTest1()"><br>
    </form>
    </body>
    </html>
    applet:
    import java.applet.Applet;
    public class Test extends Applet{
    public void test() {
         System.err.println("test");
    public void init(){
         System.out.println("this is init");
    When you open the page it should say "this is init" in the java console
    if the test button doesn't work try the getElementById way.

  • Can call an applet method directly in javascript?

    I want to call an applet method directly in javascript
    as the following format:
    function test()
    ret_val = document.myapplet.mymethod();
    myapplet is the applet name,mymethod is a
    public method in applet and it returns a string
    result,can that works?
    //thx

    Hi , i know that that is possible, i dont have the example right here just wait until tomorrow at the morning and i sent it to you , please send me a email to remaind me the code
    [email protected]

  • Invoking Applet methods from Javascript for Netscape 6

    Hi,
    I am trying to invoke an applet method from javascript, but it is failing with Netscape 6 browser:
    I am doing it the following way-
    function test(form)
    var i = document.myapplet.getname();
    where myapplet is the name of the applet and getname is a method within the applet. This is
    working with Ie but not with netscape 6.
    I would appreciate it if someone could tell me how should I invoke the applet method for netscape browsers.
    Thanks.
    Jay Srin.

    Not working with NS 6 - and will not i guess till they upgrade to Mozilla Version 1.0 - Live Connect is not implemented 100% correct yet - if you want you can download the 7.0 Pre Release Netscape - since its using mozilla 1.0 it should work , see :
    http://forum.java.sun.com/thread.jsp?forum=30&thread=272975

  • Applet ignore sign

    I have created an applet and signed it. Everything was greate until today. Suddenly when I try to sign new applets I get a message saying that the applet was signed, but when I execute it I see that it is not signed (I have checked that the expiration date hasn't passed yet).
    I tried to create a new signature this way:
    keytool -genkey -alias tkn8 -keystore tkn8 -validity 9000
    Enter keystore password: q12345
    What is your first and last name?
    [Unknown]: Tkn8
    What is the name of your organizational unit?
    [Unknown]: Computers
    What is the name of your organization?
    [Unknown]: myOrg
    What is the name of your City or Locality?
    [Unknown]: Tv
    What is the name of your State or Province?
    [Unknown]: USA
    What is the two-letter country code for this unit?
    [Unknown]: US
    Is <CN=Tkn8, OU=Computers, O=myOrg, L=Tv, ST=USA, C=US> correct?
    [no]: yes
    Enter key password for <tkina8>
    (RETURN if same as keystore password):
    I exported the signature
    keytool -export -keystore tkn8store -alias tkn8 -file tkn8.crtEnter keystore password: q12345
    Certificate stored in file <tkn8.crt>
    I installed the certificate and signed the jar
    jarsigner -keystore tkina8store TapiTkina.jar tkn8
    But it doesn't work.
    Can someone help me!!!

    You can check your java.policy.
    If there is something with "usePolicy" in there all signatures will be ignored for a certain codebase and you
    won't get the popup. Note that if you have jre and jdk installed there are more than 1 policy files.
    When you open the java console (Program Files\Java\j2re1.4.2_04\bin\jpicpl32.exe) you can set the
    runtime parameters in such a way that it will give you a full trace:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    The trace should tell you the reason why a signature is ignored.

  • Calling applet methods in forms - Problem

    I have an applet method wich creates a modal dialogue to retrieve user pin. This method is called from a form button. When the user is finished entering PIN, and the dialogue is supposed to close, it hangs. When using a button in an applet frame, this works fine, but apparently it doesent when I use my form button. Anybody have a workaround or solution to my problem?

    i guess the problem is that you can't do anything in the applet outside the dialog if it is modal and visible.
    Propably you should not make your dialog modal and just let it set a boolean variable when it is finished and keep the rest of the applet waiting for an answer with domething like:
    while(dialogstillopen)
    boolean dummy=false;

  • SetStartDate() and setEndDate() applet methods not working

    I am Using setStartDate() and setEndDate() applet methods to set Start and End Date of my XACUTE output. But its not working.
    document.<appletname>.getQueryObject().setStartDate(<Start Date>);
    document.<appletname>.getQueryObject().setEndDate(<End Date >);
    This is the part of the code i am using.

    Hi,
    It seems you are trying with proper format following things i can suggest.
    Check date time format which you are passing should be correct.
    also you can try setParam(SD,StartDate) and setParam(ED,EndDate)
    hope it helps!!
    Regards,
    Manoj Bilthare

  • Call Applet method from JavaScript, tiny test program works... SOMETIMES!?

    I have an embedded Applet in a web page, and I am trying to directly call a method in that Applet from the same page, using JavaScript.
    Here is the complete Applet:
    import java.applet.Applet;
    public class Test extends Applet {
      public String test() {
        return "test() method return value";
    }Here is the complete web page:
    <HTML>
    <HEAD><TITLE>Applet Invocation test</TITLE></HEAD>
    <BODY>
    <APPLET CODE="Test" WIDTH=10 HEIGHT=10 NAME="test"></APPLET>
    <HR>
    <SCRIPT>
    document.write( "JavaScript is working<br>" );
    document.write( document.test.test() );
    </SCRIPT>
    </BODY>
    </HTML>Is there anything wrong with this? Because it works about 15% of the time, displaying an <HR>, "JavaScript is working", and then "test() method return value" on the next line.
    The other 85% of the time, it just gets to "JavaScript is working", then I get a JavaScript error "Object does not support this property or method" for the line: document.write( document.test.test() );
    Now here's another weird quirk... I can get it to work ALL the time, if I delay the execution of the Applet method. For example, if the first line after <SCRIPT> is alert( "alert" ); then the user gets a little dialog box with "alert" message in it, and when they hit OK execution continues, and the applet method call ALWAYS works. (On a side note, if I make the Applet test() method static, it NEVER works. Why is this?)
    So it seems to me, that when it is failing, it is because the Applet is not completely loaded into the browser yet. My question is, how can I get around this?? Is there a way to instruct JavaScript to wait until the Applet is finished loading before attempting to call any methods on it?
    PS I am using Windows ME and IE 6

    Thanks for the reply, I appreciate it. I have another question, if you don't mind... here is what my new test web page looks like:
    <HTML>
    <HEAD>
    <TITLE>Applet Invocation test</TITLE>
    <SCRIPT>
    function testFunc()
      document.write( document.test.test() );
    </SCRIPT>
    </HEAD>
    <BODY onLoad="testFunc()">
    <APPLET CODE="Test" WIDTH=10 HEIGHT=10 NAME="test">
    </APPLET>
    <HR>
    </BODY>
    </HTML>What happens is: the page loads, I see a 10x10 grey applet box, and a <HR>... then a split second later, onLoad is fired, and everything on the page so far is REPLACED with the output of testFunc(), so the ONLY thing on the page after this all completes is "test() method return value"
    Why is a single document.write() statement CLEARING the page before outputting? I don't understand. If calling a document.write() from an onLoad event wipes out everything on the page, this is not extremely helpful solution.

  • Javascript to Java (Applet) method call fails in JRE1.4.1 & NN4.79

    Win2k, Netscape 4.79, JRE 1.4.1. I'm trying to call an applet method from Javascript from the page which contains the applet. 'm using MAYSCRIPT tag. I'm getting the error "myApplet doesn'nt have any properties". (myApplet is the name of the applet). When I use the default JRE which is supported by NN4.79(Symantic JRE 1.1.5) it works well. Does JRE1.4.1 plugin doesn't support Javascript to Java calls? OR I'm doing something wrong.
    Deepak

    I'm seeing the same issue. This is supposed to work. I converted the <APPLET> tags in the HTML to use <OBJECT> and <EMBED> tags using Sun's converter (see http://java.sun.com/j2se/1.4/docs/guide/plugin/developer_guide/using_tags.html). I try to reference the applet (using the document.embeds[0] object instead of the document.applets[0] object) and it seems the applet has not been loaded. I can't reference any of the methods in the applet. It appears the applet has not loaded. I do not see any evidence of the applet's init() method being called.
    Have you had any luck getting this to work?

Maybe you are looking for

  • WHY can't I get iTunes to import cd's that I put on Windows Media Player?

    I loaded about 100 cd's onto Windows Media Player prior to receiving my Nano. When I try to put them in my iTunes library, it gives me an error message about "protected WMA format" and iTunes only being able to convert unprotected WMA song AND advisi

  • How to customize the File Adapter to put the header line in a variable?

    I have a file in which the first line contains the number of records contained by the file itself. Like this: 4 record1 record2 record3 record4 where each record is a delimited list of values I need to validate that the records are actually 4. in the

  • How to Extend S-Video Cable to Watch DVDs on TV?

    My TV's built-in DVD player died, so I want to use my iMac as a DVD player but watch DVDs on the TV. The video cable (S-video?) as you know is about 6 inches long. The TV is approx. 15 feet from the iMac. Is there some sort of a cable extender to att

  • TS3694 What kind of error is (-1)?

    I recently found my old iPod Touch and I've been trying to update it to version 4.2 and an "unknown error" keeps occuring (-1). Does anyone have any information on how or what to do to fix this error. I've already updated my Mac and iTunes and the sa

  • Trouble when typing and scrolling on Curve 9300

    My girlfriend had a bb curve 9300 and has an issue when she types text and scrolls through the menus. When typing txt the phone will produce random foreign characters (the language is definetly set to english) and the cursor will move randomly throug