Applet and Robot class???

Alright, I want to write a java program uses the robot class (the class that allows for control of keybourd and mouse commands) would this work in an applet, or would it break the applet rules that ensure computer security on the web.

i just want it to work on 1 computer, is there a way that i can override the things that dont work on the net?

Similar Messages

  • Java Applets and multiple classes not working.

    I have tested my JApplet class alone to view its layout and to make sure it actually works. But once I add in my other classes, compile, jar, and test I get the error:
    java.lang.NoClassDefFoundError: AlakApp (wrong name: alak/codeFiles/AlakApp)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    4)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:155)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:618)
            at sun.applet.AppletPanel.createApplet(AppletPanel.java:779)
            at sun.applet.AppletPanel.runLoader(AppletPanel.java:708)
            at sun.applet.AppletPanel.run(AppletPanel.java:362)
            at java.lang.Thread.run(Thread.java:619)My Directory contains these and only these:
    F:\alak\codeFiles:
      AlakApp.java
      Game.java
      Board.java
      Space.java
      index.html
      AlakGame.jarAll my classes are in the package alak.codeFiles.
    My .html file contains this:
    <HTML>
    <HEAD>
      <TITLE>ALAK</TITLE>
    </HEAD>
    <BODY>
      <applet code="AlakApp.class" archive="AlakGame.jar" width=400 height=200>
      Please use a Java compatible browser to see this.
      </applet>
      <br>
    </BODY>
    </HTML>These are they commands I am issuing:
    F:\alak\codeFiles>javac *.java
    F:\alak\codeFiles>jar -cvf AlakGame.jar *.class
    F:\alak\codeFiles>appletviewer index.htmlI've been trying many different things to narrow down what is going on. If you need to see my code let me know, but I've tested everything with a text-based user interface and they work.
    So does anyone know the cause of this error?

    Ok i rared the test and uploaded to rapidshare.. here is the link:
    http://rapidshare.com/files/76860865/test.rar.html
    But here is the code. They are in the directory /test/files/
    ADigit.java
    package test.files;
    public class ADigit
      private int value;
      public ADigit( int val )
       this.value = val;
      public String toString()
       return "" + this.value;
    }ADigitApp.java
    package test.files;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ADigitApp extends JApplet implements ActionListener
      private ADigit numeroUno;
      private int currentNum;
      private Container container;
      private javax.swing.JLabel jLabel;
      private javax.swing.JTextArea jTextArea;
      private javax.swing.JButton jButton;
      public void init()
        currentNum = 1;
        numeroUno = new ADigit( currentNum );
         container = getContentPane();
        container.setLayout( new BorderLayout() );
         jLabel = new javax.swing.JLabel();
         jTextArea = new javax.swing.JTextArea();
         jLabel.setText( "The Number is: " );
         jTextArea.setText( numeroUno.toString() );
         jButton = new javax.swing.JButton();
         jButton.setText( "New Number" );
        jButton.addActionListener( this );
         container.add( jLabel, BorderLayout.WEST );
         container.add( jTextArea, BorderLayout.CENTER );
         container.add( jButton, BorderLayout.EAST );
        setSize( 200, 200 );
      public void actionPerformed( ActionEvent e )
        this.currentNum++;
         numeroUno = new ADigit( this.currentNum );
         jTextArea.setText( numeroUno.toString() );
    }index.html
    <HTML>
    <HEAD>
      <TITLE>NUMBERSSSS</TITLE>
    </HEAD>
    <BODY>
      <applet code="ADigitApp.class" archive="NumberFun.jar" width=200 height=200>
      Please use a Java compatible browser to see this.
      </applet>
      <br>
    </BODY>
    </HTML>Commands:
    /test/files>javac *.java
    /test/files>jar -cvf NumberFun.jar *.class
    /test/files>appletviewer index.htmlThis example produces the same style of error.

  • Certification Applet and Signature class

    hi
    I need a Certification Applet . how can i use Signature class for signing data with RSA_SHA_PKCS1 ?
    i need a sample code. which class is better for this purpose? Signature class or Cipher class?
    thanks,
    siavash

    i used Signature class for signing data with RSA.
    how can i use private and public keys
    for signing and verification correctly?
    i signed my data with private key and verify it with public key,
    but verify method returns false.

  • Applets and local classes

    Hi
    I have recently had to do some applet redevelopment because of some security changes introduced in jdk1.5. In the old install of the application some files were copied from the install cd to the users jvm\classes folder. These files were then used from the applet when it was downloaded from the web server. I now want to include some of these files in the jar file that contains the applet rather than use the local version installed on the users machine. The JVM seems to pick up the local classes before the ones contained in the jar. Is this by design ? or has anyone seen similar behaviour ?
    Thanks
    Paul

    There is a seporate applet forum here.
    My guess is because you are using the depreciated applet tag the applet is run with the
    msjvm. This is version 1.1.2 and eaven when it can read the class file it does not support
    swing (since 1.2 I think).
    First of all try to use the object tag
    http://java.sun.com/products/plugin/versions.html
    http://forum.java.sun.com/thread.jspa?threadID=455931&messageID=2079929
    If it still doesn't work check if code and codebase are correct:
    http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html (works the same for object
    as for applet)
    If it still doesn't work try to inspect the full trace:
    To turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)

  • Applet and Calendar class

    Hi,
    I am developing a Applet, which has lot of functions which needs calendar
    So i use Calendar.getInstance(); to get the instance if calendar
    But this applet will be used by clients all over the world,
    So i want to know, what will be the effect if i use Calendar.getInstance(); to get the instance of calendar,
    Any comments, help , or documents
    Thanx
    Ashish

    The timezone that the client machine, and the datetime format and all the other localized properties will be a part of the instance.
    Hope this helps.

  • Taking screenshot with java applet using java robot class not working

    Hi Everyone,
    I am using the java applet to take screenshot of the web browser using the java's robot class.
    Robot objRobot = new Robot ();
    BufferedImage objBufferedImage = objRobot.createScreenCapture(objRectArea);
    The thing work good in windows system taking screenshot but in case of mac osx i get the blank image.When i check the event viewer in mac osx i get the following error.
    invalid context
    invalid pixel format
    CoreAnimation: rendering error 506
    The problem is coming for all the browser safari,firefox and chrome.My applet is signed applet.
    What might be the reason.An early reply is very valuable.
    My machine configuration is as follows.
    OS : MAC OSX
    Version : 10.6.4
    Is that a system level issue , java plugin issue?I'am confused with this error.
    Thanks sagar.

    870613 wrote:
    invalid context
    invalid pixel formatHm, seems like the Mac implementation of the Robot class is doing some bad initializations there. I can't be a 100% sure of course, but this smells like a bug to me. Are you sure you have the latest version of Java installed?

  • How to load an applet with 2 classes and get it to display properly

    Ok I am a very newbie as you can tell by code below but I need help duh. I am a student taking a Java course on my own (ie no marks) so I know what I am doing in a second level java courseI am not sure if my problem is with "Forte for Java 4, CE" or my code. I have two files. Door.java and Exercise4a.java
    The code is as follows:
    Door.java
    package Exercise4.Exercise4a;
    import java.awt.*;
    import java.applet.*;
    public class Door extends java.applet.Applet {
    /** Creates a new instance of Door */
    int x;
    int y;
    public void init() {
    Graphics b;
    public Door(Point aPoint)
    x = (int)aPoint.getX();
    y = (int)aPoint.getY();
    public void paint(Graphics graphics)
    graphics.drawRect(0 + x ,0 + y, 20,30);
    graphics.setColor(Color.black);
    graphics.fillOval(15 + x,15 + y ,5,5);
    graphics.drawImage(buffer,0,0,this);
    public static void main(String args[]){}
    and Exercise4a.java
    package Exercise4.Exercise4a;
    import java.awt.*;
    import java.applet.*;
    public class Exercise4a extends java.applet.Applet {
    Graphics b;
    public void init() {
    Point a = new Point(0,0);
    Door door = new Door(a);
    My problem is that I do not see my door when I compile either file.
    What am I doing wrong? Is this acode problem. ie how do I load the graphics or is it that I am not compiling it correctly.

    package Exercise4.Exercise4a;
    import java.awt.*;
    import java.applet.*;
    public class Exercise4a extends java.applet.Applet {
    Graphics b;
    public void init() {
    Point a = new Point(0,0);
    Door door = new Door(a);// door.paint (b)

  • Robot class and positioning the cursor

    I have an application where I have a number of panels on the screen and using an editable field wish to enter coordinates to position the Cursor to on another panel.
    ie, using grid coordinates on a map. Using the robot class I am able to position the cursor on the other panel but as soon as I move the mouse the cursor jumps back to the original position on the screen where the first panel with the editable field was. It is like only a picture of the cursor was drawn at the new coordinates and the real cursor is still at the old podition. It is important to this application that if the cursor is moved it stays where it has been moved to and actually is there and not just appearing to be there. I am using jdk 1.3 on Intel Solaris 2.8. Any help on this issue would be helpful and appreciated

    Maybe you can use the mouse move event to position the mouse to where you had moved the cursor to.
    for example
    1.the mouse is at point 100,100
    2. you move the cursor from your code to point 0,0
    3. the user starts to move the mouse
    4. you code gets that event and repositions the cursor to the last place where it was, that is at 0,0

  • Robot class and keystrokes

    Can somebody help me? I have a 14000 plus line coded program. I need to generate software produced keystrokes. For example I would like to have my program hit the 'Enter' key instead of it being generated from the keyboard by a user. Now, I have just briefly been introduced to the Robot class and I am trying to understand it. I guess to use it I have to throw a AWTException. The problem is where I need to use the Robot class is in a JButton ActionListener(), which is on line 8000 nested in another frame. My question is how and where do I throw the AWTException in my program so that I can use the Robot class to generate an 'Enter' keystroke? I have noticed that in some sample programs the AWTException follows the opening
    public static void main(String[] args) throws AWTException
    statement. I tried attaching this in my program but the code nested in a AcitionListener did not recognize it.
    What I am hoping is that I can throw the exception in the following format:
    try
    Robot robot = new Robot();
    robot.keypressed(VK_ENTER);
    catch (AWTException exception)
    exception.printStackTrace();
    This is just a format I made up to show what I am looking for it has no actual copyright.
    I do not want to throw the AWTExecption for my whole program just this localized area when I need to have the software hit enter for me.
    Anyway, this is my problem can you help me out
    Derek.

    I just figured the problem out myself, by just guessing believe it or not.
    As follows :
    try
    Robot rob = new Robot():
    rob.keyPressed(VK_ENTER);
    catch(AWTException exception)
    exception.printStackTrace();
    It worked perfectly.

  • Differences between Robot class generated events and real input events

    Hello everyone!
    I'm having a problem with the translation of the description of the awt.Robot class.
    - "This class is used to generate native system input events" -
    Does this mean there is no difference between real input events and generated events from the Robot class? Difference in reference to that the generated events can't be recognized as generated events by the os or programs.
    Thanks in advance.
    Chris B.

    The Robot class will use an interface provided by the operating system to inject events. Those are very close to 'real' input events, but not quite there. There are, for instance, several games out there which have a protection mechanism against Robot's events to prevent scripting/botting. However, any application that is not paying special attention to the event's source will assume that the input events generated by Robot are actually coming from the user, so you can 'control' any application with the exception of the beforementioned games.

  • Applets and classes in jar files

    I have placed an applet and a group of classes that the applet uses in a jar file.
    The classes are grouped in their own files in a short directory tree within the jar file.
    When the applet is loaded by the browser on a client with the usual CODE="appletname.class" and ACRCHIVE="jarname.jar" statements, are the related class files and the directory tree also loaded into the client? Or do they remain at the server to be used by the applet as necessary?

    I'd say the entire JAR will be downloaded.

  • Applets and classes and jars

    ok, this has probably been asked and answered a million times, but I cannot find it anywhere.
    heres my problem:
    I have an applet and am trying to run it from internet explorer and all I get is a blank screen. the code is:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" CONFILTERED="text/html; charset=windows-1252"></meta>
    <title>Segregation of Duties</title>
    <link type="text/css" rel="stylesheet" href="department.css"/>
    <style type="text/css">
    body {
    background-color: #528cff;
    a:link { color: #528cff; }
    <applet code=mypackage.SODApplet.class archive=deploy.SODApplet.jar Height=300 Width=300>
    </applet>
    </style>
    </head>
    <body></body>
    </html>
    Apparently it cannot find the class or the jar. But how do I tell it where to find them?
    The class is in c:/jdevinstall/jdev/mywork/SOD/SODReports/classes/mypackage
    and the jar is in
    c:/jdevinstall/jdev/mywork/SOD/SODReports/deploy/
    the html is on my desktop
    Richard

    Nothing to do with Servlets here... but:
    The Applet JAR has to be in a path relative to the web page, or the server root. You are asking the client (the web browser the user is using) to download the JAR and look inside for the class to run. So the web browser must be able to see that JAR. As such it needs to be in a directory your server hosts. The easiest is to have it in a directory relative to the page that displays it, such as:
    Web Hosted Directory:   C:\Web\HostedDir\
    Web page location                       \MyApp\SODAppletPage.html
    JAR file location                       \MyApp\lib\SODApplet.jar
    Applet tag
        <applet code="mypackage.SODApplet.class"
                archive="lib/SODApplet.jar"
                Height=300 Width=300>
        </applet>

  • Robot class and obtaining mouse position

    The Robot class has the mouseMove(int x, int y) method which allows you to position the mouse at the given x-y coordinates. I am trying to move the mouse using relative coordinates, i.e. move 200 pixels left, as opposed to moving to 400,800. Is there a way to obtain my cursor's current position? I've looked at the MouseEvent class, and I'm not very sure that would work, as it requires input from the mouse in order to trigger.

    TryPointerInfo pointerInfo = MouseInfo.getPointerInfo();
    Point p = pointerInfo.getLocation();

  • Applets and certificates in jdk1.4

    Hello all...
    I have an applet which imports the java.awt.Robot class. I can not use the methods from a html page due to security restrictions...
    I've searched high and wide for documentation on how to overcome this (as i am only going to be running this applet from my own machine)...i know it involved signing and certificates - i've tried several methods but none seem to work.....does anyone have an idea of exactly how i would go about getting this working??
    Thanks in advance........
    Johnno

    Johno
    If you're only going to run this 'applet' on your own machine why not write a program instead ?

  • Applets and memory not being released by Java Plug-in

    Hi.
    I am experiencing a strange memory-management behavior of the Java Plug-in with Java Applets. The Java Plug-in seems not to release memory allocated for non-static member variables of the applet-derived class upon destroy() of the applet itself.
    I have built a simple "TestMemory" applet, which allocates a 55-megabytes byte array upon init(). The byte array is a non-static member of the applet-derived class. With the standard Java Plug In configuration (64 MB of max JVM heap space), this applet executes correctly the first time, but it throws an OutOfMemoryException when pressing the "Reload / Refresh" browser button or if pressing the "Back" and then the "Forward" browser buttons. In my opionion, this is not an expected behavior. When the applet is destroyed, the non-static byte array member should be automatically invalidated and recollected. Isn't it?
    Here is the complete applet code:
    // ===================================================
    import java.awt.*;
    import javax.swing.*;
    public class TestMemory extends JApplet
      private JLabel label = null;
      private byte[] testArray = null;
      // Construct the applet
      public TestMemory()
      // Initialize the applet
      public void init()
        try
          // Initialize the applet's GUI
          guiInit();
          // Instantiate a 55 MB array
          // WARNING: with the standard Java Plug-in configuration (i.e., 64 MB of
          // max JVM heap space) the following line of code runs fine the FIRST time the
          // applet is executed. Then, if I press the "Back" button on the web browser,
          // then press "Forward", an OutOfMemoryException is thrown. The same result
          // is obtained by pressing the "Reload / Refresh" browser button.
          // NOTE: the OutOfMemoryException is not thrown if I add "testArray = null;"
          // to the destroy() applet method.
          testArray = new byte[55 * 1024 * 1024];
          // Do something on the array...
          for (int i = 0; i < testArray.length; i++)
            testArray[i] = 1;
          System.out.println("Test Array Initialized!");
        catch (Exception e)
          e.printStackTrace();
      // Component initialization
      private void guiInit() throws Exception
        setSize(new Dimension(400, 300));
        getContentPane().setLayout(new BorderLayout());
        label = new JLabel("Test Memory Applet");
        getContentPane().add(label, BorderLayout.CENTER);
      // Start the applet
      public void start()
        // Do nothing
      // Stop the applet
      public void stop()
        // Do nothing
      // Destroy the applet
      public void destroy()
        // If the line below is uncommented, the OutOfMemoryException is NOT thrown
        // testArray = null;
      //Get Applet information
      public String getAppletInfo()
        return "Test Memory Applet";
    // ===================================================Everything works fine if I set the byte array to "null" upon destroy(), but does this mean that I have to manually set to null all applet's member variables upon destroy()? I believe this should not be a requirement for non-static members...
    I am able to reproduce this problem on the following PC configurations:
    * Windows XP, both JRE v1.6.0 and JRE v1.5.0_11, both with MSIE and with Firefox
    * Linux (Sun Java Desktop), JRE v1.6.0, Mozilla browser
    * Mac OS X v10.4, JRE v1.5.0_06, Safari browser
    Your comments would be really appreciated.
    Thank you in advance for your feedback.
    Regards,
    Marco.

    Hi Marco,
    my guess as to why JPI would keep references around, if it does keep them, is that it propably is an implementation side effect. A lot of things are cached in the name of performance and it is easy to leave things laying around in your cache. Maybe the page with the associated images/applets is kept in the browser cache untill the browser needs some memory and if the browser memory manager is not co-operating with the JPI/JVM memory manager the browser is not out of memory, thus not releasing its caches but the JVM may be out of memory. Thus the browser indirectly keeps the reference that it realy does not need. This reference could be inderect through some 'applet context' or what ever the browser uses to interact with JPI, don't realy know any of these details, just imaging what must/could be going on there. Browser are amazingly complicated beast.
    This behaviour that you are observing, weather the origin is something like I speculated or not, is not nice but I would not expect it to be fixed even if you filed a bug report. I guess we are left with relleasing all significatn memory structures in destroy. A simple way to code this is not to store anything in the member fields of the applet but in a separate class; then one has to do is to null that one reference from the applet to that class in the destroy method and everything will be relased when necessary. This way it is not easy to forget to release things.
    Hey, here is a simple, imaginary, way in which the browser could cause this problem:
    The browser, of course needs a reference to the applet, call it m_Applet here. Presume the following helper function:
    Applet instantiateAndInit(Class appletClass) {
    Applet applet=appletClass.newInstance();
    applet.init();
    return applet;
    When the browser sees the applet tag it instantiates and inits the new applet as follows:
    m_Applet=instantiateAndInit(appletClass);
    As you can readily see, the second time the instantiation occurs, the m_Applet holds the reference to the old applet until after the new instance is created and initlized. This would not cause a memory leak but would require that twice the memory needed by the applet would be required to prevent OutOfMemory.I guess it is not fair to call this sort of thing a bug but it is questionable design.In real life this is propably not this blatant, but could happen You could try, if you like, by allocating less than 32 Megs in your init. If you then do not run out of memory it is an indication that there are at most two instances of your applet around and thus it could well be someting like I've speculated here.
    br Kusti

Maybe you are looking for

  • I can't download apps on my new iphone 5s

    I downloaded one free app but after that it would not let me download anymore. It would load and then go back to the "free" button. Not only does it not work on my phone, but it also will not download any from itunes on the computer. Can anyone help?

  • PRVF-4007 : User equivalence check failed for user "grid"

    Oracle Version 11.2.0.3.0 patched to 11.2.0.3.1 I had installed GIU and RAC db on 2 node cluster but since yesterdy has this issue when running the commands [grid@vmorarac2 ~]$ cluvfy comp ocr -n all -verbose Verifying OCR integrity ERROR: PRVF-4008

  • How to make "check for multiple logons" mandatory in webdynpro application.

    Hi SDN members, Im having a problem with an application developed in webdynpro abap. We require that  end-user only have a session per computer (ip address), I already tried to achieve this by configuring the webdynpro application throguh SICF and go

  • What's the easiest way to transfer files from an old Mac to a new one?

    Alright, when I originally purchased my Macbook Pro in 2006 - I had no intentions on replacing for many, many years to come. However, purchased the 17", to have more screen space for design, and that career sort of fell through. I don't have a need f

  • Converting QT to Tiffs - No Alphas?!?

    I'm converting QT's with embedded alphas (Millions+) into Tif image sequences and it works, but it fails to preserve the alpha channel. They are missing in the newly created tifs. I've searched the Image Sequence settings but don't see any alpha opti