Thread in Applet

Halo!
I have a problem with threads who don�t want to start.
��m using tomcat 3.3 as a webserver and have written code something like this:
public class myapplet extends Applet {
TextArea text = new TextArea();
public void init() {
add(text);
mythread t = new mythread(text);
t.start();
public class mythread extends Thread {
TextArea text2;
public mythread(TextArea text) {
text2 = text;
public void run() {
//change the text in the TextArea
It works fine on localhost but not for other users

pls help me: i have a doubt. can we have Datagram Sockets in an applet (there is an argument out here) on the above.
so pls reply asap
thankz

Similar Messages

  • Creating multiple Threads in applets

    Hi, I need some help creating multiple threads in applets. If you look at the simple code example below you�ll see that it uses one thread that calls the findTarg() method that gives its sleep() a value and makes the oval find its new target.
    What I want to know is how do I create a new thread in this applet? � So for example I could call a findTarg2() method from within a new thread that sets its sleep() to a faster or slower value and starts at the same time as findTarg().
    Hope that makes sense.
    <applet code="thread.class" height=400 width=400>
    </applet>
    import java.awt.Graphics;
    import java.awt.*;
    import java.awt.event.*;
    public class thread extends java.applet.Applet implements Runnable {
    int x = 200;
    int y = 200;
    int xTarg;
    int yTarg;
    int sleeper;
    boolean go;
    Thread first;
    public void start(){
    if(first == null); {
    first = new Thread(this);
    first.start();
    public void run(){
    while (first != null) {
    findTarg();
    try {
    Thread.sleep(sleeper);
    } catch (InterruptedException e) { }
    public void findTarg(){    
    if(go == true){
    sleeper = 10;
    if(x < xTarg)x++;
    if(x > xTarg)x--;
    if(y < yTarg)y++;
    if(y > yTarg)y--;
    repaint();
    if((x == xTarg)&&(y == yTarg))go = false;
    public boolean mouseDown(Event evt, int x, int y) {
    xTarg= x;
    yTarg= y;
    go = true;
    return true;
    public void paint(Graphics g) {
    g.setColor(Color.black);
    g.fillOval(x,y,20,20);
    }

    I've found another example and this time it extends JApplet. I'm sorry I can't help you more, but I'm new as well.
    // Fig. 15.7: RandomCharacters.java
    // Demonstrating the Runnableinterface
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RandomCharacters extends JApplet
    implements Runnable,
    ActionListener {
    private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private JLabel outputs[];
    private JCheckBox checkboxes[];
    private final static int SIZE = 3;
    private Thread threads[];
    private boolean suspended[];
    public void init()
    outputs = new JLabel[ SIZE ];
    checkboxes = new JCheckBox[ SIZE ];
    threads = new Thread[ SIZE ];
    suspended = new boolean[ SIZE ];
    Container c = getContentPane();
    c.setLayout( new GridLayout( SIZE, 2, 5, 5 ) );
    for ( int i = 0; i < SIZE; i++ ) {
    outputs[ i ] = new JLabel();
    outputs[ i ].setBackground( Color.green );
    outputs[ i ].setOpaque( true );
    c.add( outputs[ i ] );
    checkboxes[ i ] = new JCheckBox( "Suspended" );
    checkboxes[ i ].addActionListener( this );
    c.add( checkboxes[ i ] );
    public void start()
    // create threads and start every time start is called
    for ( int i = 0; i < threads.length; i++ ) {
    threads[ i ] =
    new Thread( this, "Thread " + (i + 1) );
    threads[ i ].start();
    public void run()
    Thread currentThread = Thread.currentThread();
    int index = getIndex( currentThread );
    char displayChar;
    while ( threads[ index ] == currentThread ) {
    // sleep from 0 to 1 second
    try {
    Thread.sleep( (int) ( Math.random() * 1000 ) );
    synchronized( this ) {
    while ( suspended[ index ] &&
    threads[ index ] == currentThread )
    wait();
    catch ( InterruptedException e ) {
    System.err.println( "sleep interrupted" );
    displayChar = alphabet.charAt(
    (int) ( Math.random() * 26 ) );
    outputs[ index ].setText( currentThread.getName() +
    ": " + displayChar );
    System.err.println(
    currentThread.getName() + " terminating" );
    private int getIndex( Thread current )
    for ( int i = 0; i < threads.length; i++ )
    if ( current == threads[ i ] )
    return i;
    return -1;
    public synchronized void stop()
    // stop threads every time stop is called
    // as the user browses another Web page
    for ( int i = 0; i < threads.length; i++ )
    threads[ i ] = null;
    notifyAll();
    public synchronized void actionPerformed( ActionEvent e )
    for ( int i = 0; i < checkboxes.length; i++ ) {
    if ( e.getSource() == checkboxes[ i ] ) {
    suspended[ i ] = !suspended[ i ];
    outputs[ i ].setBackground(
    !suspended[ i ] ? Color.green : Color.red );
    if ( !suspended[ i ] )
    notify();
    return;
    }

  • How to create thread in applet without causing modifyThreadGroup exception?

    I've searched through this forum, and it has dozens of posts regarding infamous modifyThreadGroup exception. The two answers I continuously stumble upon are:
    1) Change something in permission file. This is unacceptable, because I'm writing an applet, which by definition should be portable.
    2) Sign the jar file. This is still unacceptable, because a) I do not know how to do this yet b) from what I've seen, process of signing is quite complicated c) I'm still in the development stage, using NetBeans 4.0, so I can't use jar's d) I just need to instantiate a freakin' thread, that's all.
    Now, instead of searching for quick fix, I want to ask couple of meaningful questions.
    1) Why some security managers do not allow me to instantiate new threads in applet? Why other security managers do? (Write once, run everywhere. Yeah, right.)
    2)How can I create thread in applet, maintaining applet's portability?
    PS: Sorry for the attitude. The case is, such things in Java irritate me greatly.

    what are you trying to do within these ThreadsMy applet needs to dynamically receive and display data from a server (also written in Java). Data changes over time, so applet needs to render this changes.
    The problem is not with the content of the thread (for there is no content yet), but with the fact that tread created at all. Here is the code that generate named exception:
            Thread receivingThread = new Thread() {
                public void run(){
                    //do something
    [quote]
    As you can see, I'm not even running a thread, but merely creating it. (Well, I will need to run it anyway, but it's the instantiation that causes problem currently.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem with threads within applet

    Hello,
    I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
    this thread is running in endless loop.
    he is doing something and go to sleep on and on.
    the problem is,
    when I refresh my IE6 browser I see more than 1 thread.
    for debug matter, I did the following things:
    inside the thread, sysout every time he goes to sleep.
    sysout in the singleton constructor.
    sysout in the singleton destructor.
    the output goes like this:
    when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
    The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
    The destructor never works (no output there).
    I don't understand what is going on.
    someone can please shed some light?
    thanks.
    btw. I am working with JRE 1.1
    this is very old and big applet and I can't convert it to something new.

    Ooops. sorry!
    I did.
         public void start() {
         public void stop() {
         public void destroy() {
              try {
                   resetAll();
                   Configuration.closeConnection();
                   QuoteItem.closeConnection();
              } finally {
                   try {
                        super.finalize();
                   } catch (Throwable e) {
                        e.printStackTrace();
         }

  • Threaded swing applet

    Hi,
    I need to write an applet that shows the results of a database query on a JTable.
    The query will be executed every second (only a few registers are retrieved from a mySQL db), and if a change is detected, the JTable must be updated.
    I've been reading about Swing and threads, and I know I must be careful when workin with threads on my GUI.
    So far, I know there exists a few methods to perform what I need, but I'm not shure which one would be the best for my app.
    The methods I'm considering are:
    - invokeLater or invokeAndWait
    - timer
    - SwingWorker
    What do you guys sugest and why ?
    Thanks

    Not sure of this, but I think you need both Timer (to query DB every second) and SwingUtilities.invokeLater (because your update task must be run outside of EDT)...
    Hope this helped a little,
    Regards.

  • WHY more Event-Dispatching threads in Applet ?

    When an applet is running, I find there are more than one Event-Dispatching Thread (EDT). I observed this through the Java Plug-in debug option -- attaching jdb.
    Swing Applications requires, access to any GUI object strictly on an Event-Dispatching Thread. Taking Event-Dispatching Thread to be a single thread, lots of synchronization consideration have been overlooked. When executing as an application, there is only one EDT; however when executing an an Applet there is more than one EDTs, but belonging to different thread groups. (like main, applet etc).
    WHY is this ?
    From a GUI developer's perspective is it safe to assume EDT is single threaded and NO sychronization issues needs to be taken care, which otherwise will be required ?
    Please let me know if you would require any more information to answer this query.
    Thanks a lot, in advance, for your time and effort. :-)
    -Soms.

    MORE supporting information:
    The jdb Thread information: (Note that there are 2 EDTs - Main and applet thread groups). I need to know WHY 2 EDTs ?
    threadsGroup system:
    (java.lang.ref.Reference$ReferenceHandler)0x9c0 Reference Handler cond. waiting
    (java.lang.ref.Finalizer$FinalizerThread)0x9c1 Finalizer cond. waiting
    (java.lang.Thread)0x9c2 Signal Dispatcher running
    (java.lang.Thread)0x9c3 Thread-1 unknown
    (sun.plugin.cache.CleanupThread)0x9c4 Cache Cleanup Thread cond. waiting
    Group main:
    (java.lang.Thread)0x9c6 main running
    (java.util.logging.LogManager$Cleaner)0x9c7 Thread-0 unknown
    (java.lang.Thread)0x9c8 AWT-Shutdown cond. waiting
    (java.lang.Thread)0x9c9 AWT-Windows running
    (java.lang.Thread)0x9ca Java2D Disposer cond. waiting
    (java.awt.EventDispatchThread)0x9cb AWT-EventQueue-0 waiting in a monitor
    Group Plugin Thread Group:
    (java.lang.Thread)0x9ce Main Console Writer cond. waiting
    Group http://rndpc192/periview/-threadGroup :
    (java.lang.Thread)0x9cf thread applet-com.peri.rnd.monitor.alaska.AlaskaApplet.class cond. waiting
    (java.lang.Thread)0x9d0 TimerQueue cond. waiting
    (java.awt.EventDispatchThread)0x9d1 AWT-EventQueue-2 waiting in a monitor
    (java.lang.Thread)0x9d2 Thread-4 waiting in a monitor
    (java.lang.Thread)0x9d3 Thread-5 unknown
    (java.lang.Thread)0x9d4 Thread-8 unknown
    (java.util.TimerThread)0x9d5 Thread-9 cond. waiting
    (java.lang.Thread)0x9d6 Thread-10 running
    (java.lang.Thread)0x9d7 Thread-12 unknown
    (java.util.TimerThread)0x9d8 Thread-13 waiting in a monitor
    (java.lang.Thread)0x9d9 Thread-14 waiting in a monitor
    (java.lang.Thread)0x9da Thread-15 cond. waiting

  • Multi thread java applet

    I cannot make multi thread applet. It seems like there is only one thread.
    Here is the code:
    public class My extends JApplet {
    public void init() {
       new Thread() {
                public void run() {
                    try {
                        nit();
                    } catch (Exception e) {
            }.run();
            int i = 99;
            try {
                getAppletContext().showDocument(new URL("javascript:alert(" + String.valueOf(i) + ")"));
            catch (MalformedURLException e) { }
           public void nit() {
            for (int i = 0; i < 5; i++) {
                this.label.setText("Brojim: " + String.valueOf(i));
                try {
                    getAppletContext().showDocument(new URL("javascript:alert(" + String.valueOf(i) + ")"));
                catch (MalformedURLException e) { }
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) { }
    }and here is the result:
    0
    1
    2
    3
    4
    99which means that after run() call it not continue the flow, but waits for thread to finish. What is the problem?
    OS: XP, browser: FF3

    You are calling run() method of Thread class. This is wrong. If you want to create new thread you should call start() method. Try the following:
    new Thread() {
                public void run() {
                    try {
                        nit();
                    } catch (Exception e) {
            }.start();

  • Mutli Threading in Applets

    hi,
    All my games so far only use a single thread to power everything from balls to tanks and paddles. I was wondering about the way at which to make any applet multi-threaded.
    I use the following:
    Runnable r = new Runnable() {
    public void run() {
    while(!dead) {
    repaint();
    try {
    Thread.sleep((int)1000/fps);
    }catch (InterruptedException ex) {
    //do nothing
    is there some way at which a method can handle the ball movement and another can handle the tank movement??                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    sure, I can tell you - but i'll have to put a
    Big disclaimer stating that this is how NOT to write games
    :D
    You want a kinda 'Manager' pattern.
    Each Manager implements the Runnable interface, and is started in its own Thread.
    Each Manager updates the game objects for which it is responsible. (i.e. the CraftManager updates all the Craft, ProjectileManager updates the Projectiles etc etc)
    the Manager then sleeps for the desired wait period between updates.
    In such a system, you would also have the rendering done in a seperate Thread.
    I warn you though, implementing such a system is a BIG waste of time.
    The Thread scheduler was never designed for such fine precision timing.
    Performance will also suffer (excessive task switching, synchronization between Threads etc etc)
    It will also get very complicated, as you try and work out exactly what needs synchronizing with what.
    Multi-threaded code is also an absolute nightmare to debug.
    If you were doing a thesis or something of that nature,
    whos aim was to discover the suitability of multi-threaded programming for games, then i'd understand the need.
    Otherwise, your just asking for trouble!

  • Blocking the applet and main threads ?

    The thread that runs the Applet callback methods like init() and start() is a thread named �applet-your.package.your.classname.class�.
    If I am doing a blocking method call, i.e. a method call that does not return immediately like doing I/O read on a socket connection, is it ok to do it on the thread mentioned above ? In other words, is it ok to hang/suspend/block the applet thread ?
    What about blocking the �main� thread that calls
    public static void main(String args[]) {�}
    Thanks.

    eminformatics, thanks for the reply.

  • JRE freeze when loading applet twice, through VSAT network

    Here is a good one for you guys I think ...
    ===========
    What I got:
    ===========
    I have a java web application, runing with Tomcat 5.5.
    I use a Apache HTTP Server 2.0.52 for my statiques ressources (html, etc ...), and the modjk connector 1.2.13 to forward all the dynamic requests from the client to the application server.
    One of my html pages contains a signed java applet.
    Basically, this applet control a scanner and send the scanned image to the web application server.
    This applet:
    - use some swing components
    - use the netscape.javascript.JSObject to call javascript functions
    - use the morena API (which include a native library) in order to control a TWAIN scanner
    - format the scanned image into a JPEG image
    - send the formatted image to the web server, using an HttpURLConnection
    (I use a servlet on server side to get the uploaded image)
    - wait for the server response, that tells my applet if the upload has been successfull or not
    Some additional infos:
    - I use morena 6.2.0.0
    - I use JRE 1.5.0.0.1 to run the applet
    - JRE on client side is configured as follow:
    - no applet caching
    - network parameters: "use the browser parameters"
    ==============
    My problem is:
    ==============
    - Through a LAN network, the applet works perfectly ...
    - Through an internet network (I use a VSAT / IDIRECT network), I can load and run my applet the first time
    but when I try to run my applet for the second time (without closing the browser), it just doesn't start, and the JRE crash
    (i.e. the java console freeze ..., just like if it was waiting for something ...)
    nothing happen after that, and I have to kill my JRE / Browser
    the funny stuff about it is that the applet works fine (even through VSAT network) when I don't upload the scanned image on the server
    load and run ok as many time as I want ...
    => seems that something's going wrong during the uploading process
    ==========================
    What I have already tried:
    ==========================
    1/ getting rid of the Java - Javascript communication (JSObject seems to have heaps of bugs ...)
    => no changes
    2/ be careful to close correctly my HttpURLConnection, with a HttpURLConnection.disconnect()
    => no changes
    3/ put the morena jars directly on the client side (in the lib/ext directory of the JRE):
    the morena API use a native library, and apparently, a native library can not be loaded by 2 different ClassLoader
    just to avoid any "java.lang.UnsatisfiedLinkError"
    as shown on http://forum.java.sun.com/thread.jspa?forumID=31&threadID=628889
    => no changes
    4/ have a closer look on the http apache server, just to get rid of the error
    "OS 64)The specified network name is no longer available. : winnt_accept: Asynchronous AcceptEx failed."
    as shown on the bug 21425 in http://issues.apache.org/bugzilla/show_bug.cgi?id=21425
    => no changes
    5/ use the upgrade version 1.5.0.6 of the JRE
    => no changes
    ==========
    ANY HELP ?
    ==========
    and as usual, I had to fix this problem for yesterday ... :)))
    Any ideas about that ?
    need more infos ?: just let me know
    ======================================================================================
    Here is the piece of code I use to upload the image from the client to the web server:
    ======================================================================================
    * Upload de cette image sur le serveur, apr�s passage au format JPEG
    * @param imageSelectionnee BufferedImage image � transf�rer
    * @throws ComposantNumerisationException exception pouvant etre lev� lors de l'upload
    public void uploadImage(BufferedImage imageSelectionnee)
        throws ComposantNumerisationException {
        // connexion http au server
        HttpURLConnection connexionServer = null;
        // flux de sortie, permettant d'envoyer les donn�es vers le serveur
        OutputStream fluxSortie = null;
        // parametres pour le libelle de l'exception
        ParametresProprietes parametres = null;
        // flux d'entr�e, pour lire la r�ponse du serveur
        BufferedReader fluxEntree = null;
        // r�ponse du serveur
        String reponseServeur = null;
        // image au format JPEG
        BufferedImage imageFormatJPEG = null;
        try {
            /* conversion de l'image au format JPEG */
            imageFormatJPEG = this.formatterImage(imageSelectionnee);
            /* ouverture d'une connexion vers le serveur */
            connexionServer = this.ouvrirConnexion(imageFormatJPEG);
            /* ecriture des donn�es dans le flux de sortie, vers le serveur */
            // cr�ation d'un outputStream
            fluxSortie = connexionServer.getOutputStream();
            // transfert des donn�es vers le serveur
            ImageIO.write(imageFormatJPEG, Constantes.TYPE_IMAGE, fluxSortie);
            fluxSortie.flush();
            /* lecture de la r�ponse du serveur */
            // cr�ation d'un flux de lecture sur le flux d'entr�e
            fluxEntree = new BufferedReader(new InputStreamReader(
                                                connexionServer.getInputStream()));
            // lecture de la r�ponse du serveur
            reponseServeur = fluxEntree.readLine();
            // v�rification du succes de l'upload, en fonction de la r�ponse du serveur
            if (!reponseServeur.startsWith("REPONSE")) {
                /* cas ou le message retour ne commence pas par "REPONSE":
                 * ce n'est pas la r�ponse de la servlet
                 *  => Tomcat nous a redirig� vers la page d'authentification */
                fenetreNumerisation.redirigerFenetreAuthentification();
            } else if (reponseServeur.compareTo("REPONSE:OK") != 0) {
                // la r�ponse du serveur indique qu'il y a eu un probl�me lors de l'upload
                throw new IOException(reponseServeur);
        } catch (IOException e) {
            // cr�ation des parametres pour ce libelle d'erreurs
            parametres = new ParametresProprietes();
            parametres.ajouterParametre("0", e.toString());
            throw new ComposantNumerisationException(
                    proprietes.getPropriete("ERREUR_UPLOAD", null),
                    proprietes.getPropriete("ERREUR_UPLOAD_TECH", parametres),
                    ComposantNumerisationException.ERREUR_NON_BLOCANTE);
        } finally {
            try {
                // fermeture de ce flux de sortie
                if (null != fluxSortie) {
                    fluxSortie.close();
                // fermeture du flux de lecture de la reponse
                if (null != fluxEntree) {
                    fluxEntree.close();
            } catch (IOException e) {
            // fermeture de la connexion
            if (null != connexionServer) {
                connexionServer.disconnect();
    * Ouverture d'une connexion vers la servlet d'upload de l'image
    * @param image BufferedImage image � transf�rer
    * @return HttpURLConnection une connexion http
    * @throws IOException exception IO
    * @throws ComposantNumerisationException exception
    private HttpURLConnection ouvrirConnexion(BufferedImage image)
        throws IOException, ComposantNumerisationException {
        // url du server
        URL urlServer = null;
        // connexion http au server
        HttpURLConnection connexionServer = null;
        // signature
        String signature = null;
        // g�n�ration de la signature de l'image � transf�rer
        signature = this.genererSignatureImage(image);
        // construction de l'url du serveur � appeler pour cet upload
        // en incluant un parametre pour transmettre la signature de l'image � transf�rer
        // + identifiant du passeport d'urgence courant
        urlServer = new URL(this.urlServeur + this.action +
                            "?" + Constantes.PARAM_SIGNATURE_IMAGE + "=" + signature +
                            "&" + Constantes.PARAM_IDDEMANDE + "=" + idDemande +
                            "&" + Constantes.PARAM_CODEMAJ + "=" + codeMaj +
                            "&" + Constantes.PARAM_TYPEDEMANDE + "=" + typeDemande);
        if (null == urlServer) {
            throw new IOException(proprietes.getPropriete(
                                "ERREUR_UPLOAD_CREATION_URL_SERVEUR", null));
        // ouverture d'une connexion http, gr�ce a cette url du server
        connexionServer = (HttpURLConnection) urlServer.openConnection();
        if (null == connexionServer) {
            throw new IOException(proprietes.getPropriete(
                    "ERREUR_UPLOAD_OUVERTURE_CONNEXION_SERVEUR", null));
        // param�trage de cette connexion
        // m�thode de transmission = POST
        connexionServer.setRequestMethod("POST");
        // autorisation de lire les donn�es venant du serveur
        connexionServer.setDoInput(true);
        // autorisation d'�crire des donn�es vers le serveur                         
        connexionServer.setDoOutput(true);
        // pas d'utilisation de caches
        connexionServer.setUseCaches(false);
        connexionServer.setDefaultUseCaches(false);
        // sp�cification du type des donn�es que l'on envoie vers le serveur
        connexionServer.setRequestProperty("content-type", "img/jpeg");
        return connexionServer;
    }=======================================================================================
    Here is the piece of code I use on server side to get the scaned image from the client:
    =======================================================================================
    * Lecture des donn�es en provenance de l'applet
    * @param request HttpServletRequest
    * @return ByteArrayOutputStream buffer contenant les donn�es lues
    * @throws TechnicalException exception
    * @throws FunctionalException si erreur fonctionnelle
    private ByteArrayOutputStream lireDonnees(HttpServletRequest request)
        throws FunctionalException, TechnicalException {
        // stream de sortie sur l'image
        ByteArrayOutputStream baos = null;
        // id du passeport d'urgence au format Integer
        // image issue de l'applet
        BufferedImage image = null;
        try {
            /* r�cup�ration de l'image */
            image = ImageIO.read(request.getInputStream());
            if (null == image) {
                logger.error(THIS_CLASS + Libelles.getLibelle("ERR-TEC-16", null));
                throw new TechnicalException(new ErreurVO("ERR-TEC-16",
                        null, "", true, false, false));
        } catch (IllegalArgumentException e) {
            logger.error(THIS_CLASS + Libelles.getLibelle("ERR-TEC-13", null));
            throw new TechnicalException(new ErreurVO("ERR-TEC-13",
                    null, "", true, false, false));
        } catch (IOException e) {
            logger.error(THIS_CLASS + Libelles.getLibelle("ERR-TEC-16", null));
            throw new TechnicalException(new ErreurVO("ERR-TEC-16",
                    null, "", true, false, false));
        return baos;
    * Ecriture de la reponse � envoyer � l'applet
    * @param response HttpServletResponse
    * @param erreur Message d'erreur
    * @throws IOException exception
    private void ecrireReponse(HttpServletResponse response, String erreur) throws IOException {
        // r�ponse � envoyer � l'applet
        String reponseServer = null;
        // flux de reponse
        PrintWriter fluxReponse = null;
        response.setContentType("text/html");
        // construction de la r�ponse � envoyer � l'applet
        if (null == erreur) {
            reponseServer = "REPONSE:OK";
        } else {
            /* cas ou il y a eu une exception lev�e lors de la reception des donn�es */
            reponseServer = "REPONSE:ERREUR:" + erreur;
        if (logger.isDebugEnabled()) {
            logger.debug(THIS_CLASS +
                    "Envoie de la r�ponse � l'applet, indiquant si l'upload s'est bien d�roul�: " +
                    reponseServer);
        //envoie de la r�ponse a l'applet
        fluxReponse = response.getWriter();
        fluxReponse.println(reponseServer);
        fluxReponse.close();
    }==============================================================================
    here is the traces I get when the applet doesn't work, through a VSAT network:
    ==============================================================================
    Java Plug-in 1.5.0_01
    Utilisation de la version JRE 1.5.0_01 Java HotSpot(TM) Client VM
    R�pertoire d'accueil de l'utilisateur = C:\Documents and Settings\assistw
    network: Chargement de la configuration du proxy d�finie par l'utilisateur ...
    network: Termin�.
    network: Chargement de la configuration du proxy � partir de Netscape Navigator ...
    network: Erreur lors de la lecture du fichier de registre : C:\Documents and Settings\assistw\Application Data\Mozilla\registry.dat
    network: Termin�.
    network: Chargement de la configuration proxy du navigateur ...
    network: Termin�.
    network: Configuration du proxy : Configuration du proxy du navigateur
    basic: Le cache est d�sactiv� par l'utilisateur
    c:   effacer la fen�tre de la console
    f:   finaliser les objets de la file d'attente de finalisation
    g:   lib�rer la m�moire
    h:   afficher ce message d'aide
    l:   vider la liste des chargeurs de classes
    m:   imprimer le relev� d'utilisation de la m�moire
    o:   d�clencher la consignation
    p:   recharger la configuration du proxy
    q:   masquer la console
    r:   recharger la configuration des politiques
    s:   vider les propri�t�s syst�me et d�ploiement
    t:   vider la liste des threads
    v:   vider la pile des threads
    x:   effacer le cache de chargeurs de classes
    0-5: fixer le niveau de tra�age � <n>
    basic: R�cepteur de modalit�s enregistr�
    basic: R�f�rence au chargeur de classes : sun.plugin.ClassLoaderInfo@b30913, refcount=1
    basic: R�cepteur de progression ajout� : sun.plugin.util.GrayBoxPainter@77eaf8
    basic: Chargement de l'applet...
    basic: Initialisation de l'applet...
    basic: D�marrage de l'applet...
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    security: Acc�s aux cl�s et au certificat dans le profil utilisateur Mozilla : null
    security: Chargement des certificats AC racine depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
    security: Certificats AC racine charg�s depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
    security: Chargement des certificats JPI depuis C:\Documents and Settings\assistw\Application Data\Sun\Java\Deployment\security\trusted.certs
    security: Certificats JPI charg�s depuis C:\Documents and Settings\assistw\Application Data\Sun\Java\Deployment\security\trusted.certs
    security: Chargement des certificats JPI depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\trusted.certs
    security: Certificats JPI charg�s depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\trusted.certs
    security: Chargement des certificats depuis la zone de stockage des certificats de session JPI
    security: Certificats charg�s depuis la zone de stockage des certificats de session JPI
    security: Recherche du certificat dans le magasin de certificats permanent JPI
    security: Recherche du certificat dans la zone de stockage des certificats de session JPI
    security: Obtenir l'objet de stockage des cl�s de la zone de stockage des certificats AC racine
    security: Obtenir l'objet de stockage des cl�s de la zone de stockage des certificats AC racine
    security: Recherche du certificat dans la zone de stockage des certificats AC racine
    security: D�terminer si le certificat peut �tre v�rifi� � l'aide des certificats de la zone de stockage des certificats AC racine
    ... [check certifications]
    sun.misc.Launcher$ExtClassLoader@92e78c
    <no principals>
    java.security.Permissions@157b46f (
    (java.lang.RuntimePermission stopThread)
    (java.security.AllPermission <all permissions> <all actions>)
    (java.io.FilePermission \C:\Program Files\Java\jre1.5.0_01\lib\ext\sunjce_provider.jar read)
    (java.util.PropertyPermission java.version read)
    (java.util.PropertyPermission java.vm.name read)
    (java.util.PropertyPermission java.vm.vendor read)
    (java.util.PropertyPermission os.name read)
    (java.util.PropertyPermission java.vendor.url read)
    (java.util.PropertyPermission java.vm.specification.vendor read)
    (java.util.PropertyPermission java.specification.vendor read)
    (java.util.PropertyPermission os.version read)
    (java.util.PropertyPermission java.specification.name read)
    (java.util.PropertyPermission java.class.version read)
    (java.util.PropertyPermission file.separator read)
    (java.util.PropertyPermission java.vm.version read)
    (java.util.PropertyPermission os.arch read)
    (java.util.PropertyPermission java.vm.specification.name read)
    (java.util.PropertyPermission java.vm.specification.version read)
    (java.util.PropertyPermission java.specification.version read)
    (java.util.PropertyPermission java.vendor read)
    (java.util.PropertyPermission path.separator read)
    (java.util.PropertyPermission line.separator read)
    (java.net.SocketPermission localhost:1024- listen,resolve)
    ... [check certifications]
    security: La v�rification du certificat � l'aide des certificats AC racine a �chou�
    security: Aucune information d'horodatage disponible
    basic: Modalit� empil�e
    basic: Modalit� d�sempil�e
    basic: Utilisateur s�lectionn� : 0
    security: L'utilisateur a accord� les droits d'acc�s au code pour cette session seulement
    security: Ajout du certificat dans la zone de stockage des certificats de session JPI
    security: Certificat ajout� dans la zone de stockage des certificats de session JPI
    security: Enregistrement des certificats dans la zone de stockage des certificats de session JPI
    security: Certificats enregistr�s dans la zone de stockage des certificats de session JPI
    ... [check certifications]
    sun.plugin.security.PluginClassLoader@10fe2b9
    <no principals>
    java.security.Permissions@fe315d (
    (java.lang.RuntimePermission accessClassInPackage.sun.audio)
    (java.lang.RuntimePermission stopThread)
    (java.security.AllPermission <all permissions> <all actions>)
    (java.util.PropertyPermission java.version read)
    (java.util.PropertyPermission java.vm.name read)
    (java.util.PropertyPermission javaplugin.version read)
    (java.util.PropertyPermission java.vm.vendor read)
    (java.util.PropertyPermission os.name read)
    (java.util.PropertyPermission java.vendor.url read)
    (java.util.PropertyPermission java.vm.specification.vendor read)
    (java.util.PropertyPermission java.specification.vendor read)
    (java.util.PropertyPermission os.version read)
    (java.util.PropertyPermission browser.vendor read)
    (java.util.PropertyPermission java.specification.name read)
    (java.util.PropertyPermission java.class.version read)
    (java.util.PropertyPermission file.separator read)
    (java.util.PropertyPermission browser.version read)
    (java.util.PropertyPermission java.vm.version read)
    (java.util.PropertyPermission os.arch read)
    (java.util.PropertyPermission browser read)
    (java.util.PropertyPermission java.vm.specification.name read)
    (java.util.PropertyPermission java.vm.specification.version read)
    (java.util.PropertyPermission java.specification.version read)
    (java.util.PropertyPermission java.vendor read)
    (java.util.PropertyPermission path.separator read)
    (java.util.PropertyPermission http.agent read)
    (java.util.PropertyPermission line.separator read)
    (java.net.SocketPermission rma_phileas connect,accept,resolve)
    (java.net.SocketPermission localhost:1024- listen,resolve)
    ... [check certifications]
    sun.misc.Launcher$ExtClassLoader@92e78c
    <no principals>
    java.security.Permissions@bd09e8 (
    (java.lang.RuntimePermission stopThread)
    (java.security.AllPermission <all permissions> <all actions>)
    (java.io.FilePermission \C:\Program Files\Java\jre1.5.0_01\lib\ext\Smorena.jar read)
    (java.util.PropertyPermission java.version read)
    (java.util.PropertyPermission java.vm.name read)
    (java.util.PropertyPermission java.vm.vendor read)
    (java.util.PropertyPermission os.name read)
    (java.util.PropertyPermission java.vendor.url read)
    (java.util.PropertyPermission java.vm.specification.vendor read)
    (java.util.PropertyPermission java.specification.vendor read)
    (java.util.PropertyPermission os.version read)
    (java.util.PropertyPermission java.specification.name read)
    (java.util.PropertyPermission java.class.version read)
    (java.util.PropertyPermission file.separator read)
    (java.util.PropertyPermission java.vm.version read)
    (java.util.PropertyPermission os.arch read)
    (java.util.PropertyPermission java.vm.specification.name read)
    (java.util.PropertyPermission java.vm.specification.version read)
    (java.util.PropertyPermission java.specification.version read)
    (java.util.PropertyPermission java.vendor read)
    (java.util.PropertyPermission path.separator read)
    (java.util.PropertyPermission line.separator read)
    (java.net.SocketPermission localhost:1024- listen,resolve)
    scl:
    Morena - Image Acquisition Framework version 6.2.0.0.
    Copyright (c) Gnome s.r.o. 1999-2004. All rights reserved.
    Licensed to "XXX".
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageInputStreamSpi avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageInputStreamSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageOutputStreamSpi avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageOutputStreamSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageTranscoderSpi avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageTranscoderSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageReaderSpi avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageReaderSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageWriterSpi avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageWriterSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    network: Connexion de http://rma_phileas/Client/flux/protected/uploadimage.do?signature=c07690c12904320a253cbdeeded59238&idDemande=7&codeMaj=1133967329473&typeDemande=PU avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/flux/protected/uploadimage.do?signature=c07690c12904320a253cbdeeded59238&idDemande=7&codeMaj=1133967329473&typeDemande=PU avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
    basic: Arr�t de l'applet...
    basic: R�cepteur de progression supprim� : sun.plugin.util.GrayBoxPainter@77eaf8
    basic: Jonction du thread d'applet...
    basic: Destruction de l'applet...
    basic: Elimination de l'applet...
    basic: Sortie de l'applet...
    basic: Thread d'applet joint...
    basic: R�cepteur de modalit�s non enregistr�
    basic: Recherche d'informations...
    basic: Lib�ration du chargeur de classes : sun.plugin.ClassLoaderInfo@b30913, refcount=0
    basic: Mise en cache du chargeur de classes : sun.plugin.ClassLoaderInfo@b30913
    basic: Taille de cache du chargeur de classes courant : 1
    basic: Termin�...
    basic: R�cepteur de modalit�s enregistr�
    basic: R�f�rence au chargeur de classes : sun.plugin.ClassLoaderInfo@b30913, refcount=1
    basic: R�cepteur de progression ajout� : sun.plugin.util.GrayBoxPainter@1e16483
    basic: Chargement de l'applet...
    basic: Initialisation de l'applet...
    basic: D�marrage de l'applet...
    network: Connexion de http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec proxy=DIRECT
    network: Connexion http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"

    A workaround would be: don't use IE9. You want a solution, not a workaround.
    I think at this juncture you are best of creating a new bug report and be sure to reference the old closed one. It doesn't look entirely related though, your symptoms are different from what is described in it (freeze VS a crash). You tried this on several systems right? Also on machines on a different network?
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7072601

  • Signed applet don't work on XP

    Hi,
    I'am currently working on a point-of-sale (POS) using windows XP/Firefox and a linux apache/jboss server.
    I have developed a dynamic windows library in order to use an industrial printer connected to the POS to perform some printing without confirmation of the customer.
    The POS is under Windows XP SP2 and use Firefox 2.0.0.11/JRE 1.5.0.14.
    This dll is used by a signed applet located on the apache/jboss server.
    The applet is correctly downloaded by the client, but normally i have to wait for the certicat authentification windows appearing and for confirming that i want execute the applet. And instead i have a java exception :
    security: La v�rification du certificat � l'aide des certificats AC racine a �chou�
    security: Aucune information d'horodatage disponible
    java.lang.NullPointerException
         at com.sun.deploy.ui.UIFactory.showSecurityDialog(Unknown Source)
         at com.sun.deploy.security.TrustDeciderDialog.showDialog(Unknown Source)
         at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source)
         at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source)
         at sun.plugin.security.PluginClassLoader.getPermissions(Unknown Source)
         at java.security.SecureClassLoader.getProtectionDomain(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.access$100(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         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)
    security: L'utilisateur a refus� les droits d'acc�s au code
    basic: Taille de cache du chargeur de classes courant : 1
    basic: Termin�...
    basic: Jonction du thread d'applet...
    basic: Destruction de l'applet...
    basic: Elimination de l'applet...
    basic: Sortie de l'applet...
    java.lang.ExceptionInInitializerError
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(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.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.C:\Program Files\BICImpression\impression_api.dll)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkLink(Unknown Source)
         at java.lang.Runtime.load0(Unknown Source)
         at java.lang.System.load(Unknown Source)
         at applets.impression.Impression.<clinit>(Impression.java:38)
         ... 11 moreand then the certicat authentification windows appears but it's too late, the applet won't never execute ...
    the apache/jboss server is accessed via some gateway, firewal, ... tha t i can't control
    the apache jboss/server on my own PC is accessed directly :
    What is amazing, is that work fine with my own professionnal PC on W2000 SP4, with JRE1.5.0.14 and Firefox 2.0.0.11 :
    when I look in the java console, the java freeze until i have answered this java security window (certicat authentification windows). And when i answered "run" no problem the applet makes her own job.
    here is the code when it works :
    security: La v�rification du certificat � l'aide des certificats AC racine a �chou�
    security: Aucune information d'horodatage disponible
    basic: Plugin modality.pushed
    basic: Modalit� empil�e
    basic: push javax.swing.JDialog[dialog0,379,296,519x323,layout=java.awt.BorderLayout,modal,title=Avertissement - S�curit�,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,3,22,513x298,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
    basic: Chargement arr�t�...
    basic: Arr�t de l'applet...Conclusion
    POS : Win XP SP2, JRE1.5.0.14 (i tried 1.5.0.6 and 1.6.3 the latest), Firefox 2.0.0.11 (I tried 2.0.0.0 and 3 beta2 don't work anyway)
    my own server/client : W2000 SP4, JRE1.5.0.14, Firefox 2.0.0.11
    Linux server : RHEL4
    It works with IE on the POS with the linux sever but it's not the selected browser.
    It works with IE on the POS with my own server.
    It works with Firefox on the POS with my own server.
    It works with IE on my own server with the linux sever but it's not the selected browser.
    It works with IE on my own server with my own server.
    It works with Firefox on my own server with the linux sever.
    It works with Firefox on my own server with my own server.
    If you have some idea to make it work i'm you're buyer !!
    Thank a lot for reading this, and i apologize for my poor english ...
    greetings,
    Benoit
    Edited by: bendur on Feb 29, 2008 3:49 AM

    Ok I have found my problem :
    On every web pages, we have defined some inactivity timeouts.
    On my own server I have disabled these timeouts but not on the distant timeout.
    And it seems that the timeout (defined in javascript ont he web pages : 3s) has a very bad influence on the launching of my applet ... only with firefox (with IE and Opera no problem)
    My problem is anwsered but the problem keep alive for firefox ...

  • Applet has illegal start of expression at public VNCViewer() method{  )

    package viewer;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Label;
    public class VNCViewer extends java.applet.Applet implements Runnable
      public static final String version = "4.1";
      public static final String about1 = "VNC Viewer Free Edition "+version;
      public static final String about2 = "Copyright (C) 2002-2005 RealVNC Ltd.";
      public static final String about3 = ("See http://www.realvnc.com for "+
                                           "information on VNC.");
      public static final String aboutText = about1+"\n"+about2+"\n"+about3;
      public static void main(String[] argv) {
        VNCViewer viewer = new VNCViewer(argv);
        viewer.start();
      public VNCViewer(String[] argv) {
        applet = false;
        // Override defaults with command-line options
        for (int i = 0; i < argv.length; i++) {
          if (argv.equalsIgnoreCase("-log")) {
    if (++i >= argv.length) usage();
    System.err.println("Log setting: "+argv[i]);
    rfb.LogWriter.setLogParams(argv[i]);
    continue;
    if (rfb.Configuration.setParam(argv[i]))
    continue;
    if (argv[i].charAt(0) == '-') {
    if (i+1 < argv.length) {
    if (rfb.Configuration.setParam(argv[i].substring(1), argv[i+1])) {
    i++;
    continue;
    usage();
    if (vncServerName.getValue() != null)
    usage();
    vncServerName.setParam(argv[i]);
    public static void usage() {
    String usage = ("\nusage: vncviewer [options/parameters] "+
    "[host:displayNum] [options/parameters]\n"+
    //" vncviewer [options/parameters] -listen [port] "+
    //"[options/parameters]\n"+
    "\n"+
    "Options:\n"+
    " -log <level> configure logging level\n"+
    "\n"+
    "Parameters can be turned on with -<param> or off with "+
    "-<param>=0\n"+
    "Parameters which take a value can be specified as "+
    "-<param> <value>\n"+
    "Other valid forms are <param>=<value> -<param>=<value> "+
    "--<param>=<value>\n"+
    "Parameter names are case-insensitive. The parameters "+
    "are:\n\n"+
    rfb.Configuration.listParams());
    //System.err.print(usage);
    //System.exit(1);
    //Illegal Start of Expression is here...
    public VNCViewer() {
    applet = true;
    firstApplet = true;
    public static void newViewer(VNCViewer oldViewer) {
    VNCViewer viewer = new VNCViewer();
    viewer.applet = oldViewer.applet;
    viewer.firstApplet = false;
    viewer.start();
    public void init() {
    vlog.debug("init called");
    setBackground(Color.white);
    logo = getImage(getDocumentBase(), "logo150x150.gif");
    public void start() {
    vlog.debug("start called");
    nViewers++;
    if (firstApplet) {
    alwaysShowServerDialog.setParam(true);
    rfb.Configuration.readAppletParams(this);
    String host = getCodeBase().getHost();
    if (vncServerName.getValue() == null && vncServerPort.getValue() != 0) {
    int port = vncServerPort.getValue();
    vncServerName.setParam(host + ((port >= 5900 && port <= 5999)
    ? (":"+(port-5900))
    : ("::"+port)));
    thread = new Thread(this);
    thread.start();
    public void paint(Graphics g) {
    g.drawImage(logo, 0, 0, this);
    int h = logo.getHeight(this)+20;
    g.drawString(about1, 0, h);
    h += g.getFontMetrics().getHeight();
    g.drawString(about2, 0, h);
    h += g.getFontMetrics().getHeight();
    g.drawString(about3, 0, h);
    public void run() {
    CConn cc = null;
    try {
    cc = new CConn(this);
    if (cc.init(null, vncServerName.getValue(),
    alwaysShowServerDialog.getValue())) {
    while (true)
    cc.processMsg();
    } catch (rdr.EndOfStream e) {
    vlog.info(e.toString());
    } catch (Exception e) {
    if (cc != null) cc.removeWindow();
    if (cc == null || !cc.shuttingDown) {
    e.printStackTrace();
    new MessageBox(e.toString());
    if (cc != null) cc.removeWindow();
    nViewers--;
    if (!applet && nViewers == 0) {
    System.exit(0);
    rfb.BoolParameter fastCopyRect
    = new rfb.BoolParameter("FastCopyRect",
    "Use fast CopyRect - turn this off if you get "+
    "screen corruption when copying from off-screen",
    true);
    rfb.BoolParameter useLocalCursor
    = new rfb.BoolParameter("UseLocalCursor",
    "Render the mouse cursor locally", true);
    rfb.BoolParameter autoSelect
    = new rfb.BoolParameter("AutoSelect",
    "Auto select pixel format and encoding", true);
    rfb.BoolParameter fullColour
    = new rfb.BoolParameter("FullColour",
    "Use full colour - otherwise 6-bit colour is used "+
    "until AutoSelect decides the link is fast enough",
    false);
    rfb.AliasParameter fullColor
    = new rfb.AliasParameter("FullColor", "Alias for FullColour", fullColour);
    rfb.StringParameter preferredEncoding
    = new rfb.StringParameter("PreferredEncoding",
    "Preferred encoding to use (ZRLE, hextile or"+
    " raw) - implies AutoSelect=0", null);
    rfb.BoolParameter viewOnly
    = new rfb.BoolParameter("ViewOnly", "Don't send any mouse or keyboard "+
    "events to the server", false);
    rfb.BoolParameter shared
    = new rfb.BoolParameter("Shared", "Don't disconnect other viewers upon "+
    "connection - share the desktop instead", false);
    rfb.BoolParameter acceptClipboard
    = new rfb.BoolParameter("AcceptClipboard",
    "Accept clipboard changes from the server", true);
    rfb.BoolParameter sendClipboard
    = new rfb.BoolParameter("SendClipboard",
    "Send clipboard changes to the server", true);
    rfb.BoolParameter alwaysShowServerDialog
    = new rfb.BoolParameter("AlwaysShowServerDialog",
    "Always show the server dialog even if a server "+
    "has been specified in an applet parameter or on "+
    "the command line", false);
    rfb.StringParameter vncServerName
    = new rfb.StringParameter("Server",
    "The VNC server <host>[:<dpyNum>] or "+
    "<host>::<port>", null);
    rfb.IntParameter vncServerPort
    = new rfb.IntParameter("Port",
    "The VNC server's port number, assuming it is on "+
    "the host from which the applet was downloaded", 0);
    Thread thread;
    boolean applet, firstApplet;
    Image logo;
    Label versionLabel;

    Looks like you have at least two missing "}"
    You have commented out one that you seem to need, right at the error.

  • In need of thread help...please!

    Have a map like applet running on netscape6.2 and IE5.0 both using the java plug-in 1.4. Here is the deal, want to make applet as a thread so I can stop and start at will. Unfortunately my applet wont show as a thread. It runs all the way through to the run and just stays at run, but doesnt show the "Map". Whereas it shows the map without the thread. Reason I'm trying to do the thread is b/c of post: "cache or stop/start problem" Please help!
    Code before thread:
    public class myApplet extends JApplet
    public MapObj map;
    public myApplet() {}
    public void init()
    System.out.println("DApplet: init");
    try
    jbInit();
    catch(Exception e)
    e.printStackTrace();
    private void jbInit() throws Exception
    addComponentListener(new java.awt.event.ComponentAdapter()
    public void componentResized(java.awt.event.ComponentEvent e)
    java.awt.Component c = e.getComponent();
    Map = new MapObj(int, int);
    getContentPane().add(Map);
    public void start()
    System.out.println("DApplet: started");
    public void stop() {
    System.gc();
    System.out.println("DApplet: stoped");
    public void destroy()
    System.out.println("DApplet: destroyed");
    Code after thread:
    public class DApplet extends JApplet implements Runnable{
    public MapObj Map;
    public Thread AppletThread = null;
    public myApplet() {}
    public void init()
    try
    jbInit();
    catch(Exception e)
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception
    java.awt.Dimension sd = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    addComponentListener(new java.awt.event.ComponentAdapter()
    public void componentResized(java.awt.event.ComponentEvent e) {
    java.awt.Component c = e.getComponent();}
    Map = new MapObj(int, int);
    public void start()
    if(AppletThread == null)
    AppletThread = new Thread(this, "myApplet");
    AppletThread.start();
    public void stop()
    AppletThread = null;
    System.gc();
    public void run()
    getContentPane().add(Map);
    }

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import java.lang.*;
    import java.*;
    public class Applet extends JApplet implements Runnable{
    boolean isStandalone = false;
    public MapObj Map;
    private int winW =1960;
    private int winH = 1700;
    public Thread AppletThread;
    public DApplet() {
    public void run(){
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    java.awt.Dimension sd = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    winW = sd.width - 30;
    winH = sd.height - 30;
    setSize(winW, winH);
    addComponentListener(new java.awt.event.ComponentAdapter() {
    public void componentResized(java.awt.event.ComponentEvent e) {
    java.awt.Component c = e.getComponent();
    Map = new MapObj(winW, winH);
    getContentPane().add(Map);
    public void start() {
    if(AppletThread == null)
         AppletThread = new Thread(this, "Applet");
         AppletThread.start();
    public void stop() {
    AppletThread.stop();
    AppletThread = null;
    System.exit();
    System.gc();
    public void destroy()
    System.gc();
    }

  • How to embed an applet in a JPanel

    Hi All,
    I am in need of serious help as I have not been able to figure this out for days!!!
    All I want to do is to display a runnable applet in a JPanel.
    The applet is shown below. Its a ball bouncing around. All I need to do is to embed this in a Jpanel with buttons which will control the movement of the ball in the applet which should be on a Panel. For the life of me I havent figured it out!
    Can someone help a brother out!
    import java.awt.*;
    import javax.swing.*;
    import java.applet.Applet;
    import java.awt.*;
    import javax.swing.JOptionPane;
    import javax.swing.*;
    import java.awt.event.*;
    //Animation Class
    class Animation extends Thread {
    private Applet appl;
    private Color color;
    private int increment, vincrement;
    private int which;
    private int position = 0;
    private int vposition = 0;
    public int xCenter, yCenter;
    private int pause;
    private int width, height, speed;
    private double distance;
    private Dimension[] rotations;
    private int currentRotation ;
    Animation(Applet a, Color c, int p, int wid, int hei ,int theSpeed, int Start) {
    color = c;
    appl = a;
    pause = p;
    width = wid;
    height = hei;
    speed = theSpeed;
    rotations = new Dimension[8];
    rotations[0] = new Dimension(1,0);
    rotations[1] = new Dimension(1,-1);
    rotations[2] = new Dimension(0,-1);
    rotations[3] = new Dimension(-1 , -1);
    rotations[4] = new Dimension(-1,0);
    rotations[5] = new Dimension(-1,1);
    rotations[6] = new Dimension(1,0);
    rotations[7] = new Dimension(1,1);
    currentRotation = Start;
    increment = (int)rotations[Start].getWidth();
    vincrement = (int)rotations[Start].getHeight();
    setSpeed();
    public void setSpeed()
    {  increment = increment*speed;
    vincrement = vincrement * speed;
    public void changeRotation(int run, int rise){
    increment = run;
    vincrement = rise;
    setSpeed();
    public void rotate(){
    currentRotation++;
    if (currentRotation == 8)
    currentRotation = 0;
    changeRotation((int)rotations[currentRotation].getWidth(), (int)rotations[currentRotation].getHeight() );
    public void bounce(){
    increment = -increment;
    public void vBounce(){
    vincrement = -vincrement;
    public void setColor(Color n)
    color = n;
    public void run() {
    while (true) {
    try {
    Thread.sleep(pause);
    } catch (InterruptedException e) {}
    position += increment;
    if (position > width - 30 || position <= 0)
    { increment = -increment;
    vposition += vincrement;
    if (vposition > height - 30 || vposition <= 0)
    { vincrement= -vincrement;
    appl.repaint();
    public void draw(Graphics g) {
    g.setColor(color);
    g.fillOval(0 + position, 0 + vposition,30, 30);
    setCentre();
    public void setCentre(){
    xCenter = position - 30/2;
    yCenter = vposition -30/2;
    public boolean didCollide(Animation x){
    distance = Math.sqrt( Math.pow( (xCenter- x.xCenter) ,2) + Math.pow((yCenter-x.yCenter) , 2) );
    if (distance <= 31){
    return true;
    }else return false;
    }

    I took the liberty to make few changes:
    the applet:
    import java.awt.*;
    public class AnimA extends java.applet.Applet
         Animation anim;
         int p   = 70;
         int wid = 400;
         int hei = 300;
        int theSpeed = 2;
         int start    = 7;
    public void init()
         setLayout(new BorderLayout());
         anim = new Animation(Color.green,p,wid,hei,theSpeed,start);     
         add("Center",anim);
         Panel panel = new Panel();
         panel.setBackground(Color.lightGray);
         panel.add(new Button("Button 1"));
         panel.add(new Button("Button 1"));
         add("South",panel);
         Thread th = new Thread(anim);
         th.start();
    the animation
    import java.awt.*;
    import java.awt.event.*;
    //Animation Class
    class Animation extends Panel implements Runnable
    //     private Applet      appl;
         private Color       color;
         private int         increment, vincrement;
         private int         which;
         private int         position = 0;
         private int         vposition = 0;
         public  int         xCenter, yCenter;
         private int         pause;
         private int         width, height, speed;
         private double      distance;
         private Dimension[] rotations;
         private int         currentRotation ;
    Animation(Color c, int p, int wid, int hei ,int theSpeed, int Start)
         color  = c;
    //     appl   = a;
         pause  = p;
         width  = wid;
         height = hei;
         speed  = theSpeed;
         rotations = new Dimension[8];
         rotations[0] = new Dimension(1,0);
         rotations[1] = new Dimension(1,-1);
         rotations[2] = new Dimension(0,-1);
         rotations[3] = new Dimension(-1 , -1);
         rotations[4] = new Dimension(-1,0);
         rotations[5] = new Dimension(-1,1);
         rotations[6] = new Dimension(1,0);
         rotations[7] = new Dimension(1,1);
         currentRotation = Start;
         increment  = (int)rotations[Start].getWidth();
         vincrement = (int)rotations[Start].getHeight();
         setSpeed();
    public void setSpeed()
         increment  = increment  * speed;
         vincrement = vincrement * speed;
    public void changeRotation(int run, int rise){
         increment  = run;
         vincrement = rise;
         setSpeed();
    public void rotate()
         currentRotation++;
         if (currentRotation == 8) currentRotation = 0;
         changeRotation((int)rotations[currentRotation].getWidth(), (int)rotations[currentRotation].getHeight() );
    public void bounce()
         increment  = -increment;
    public void vBounce()
         vincrement = -vincrement;
    public void setColor(Color n)
         color = n;
    public void run()
         while (true)
              try
                   Thread.sleep(pause);
               catch (InterruptedException e) {}
              repaint(position,vposition,31,31);
              position  += increment;
              if (position > width - 30 || position <= 0) bounce();
              vposition += vincrement;
              if (vposition >= height - 30 || vposition <= 0) vBounce();
              repaint(position,vposition,31,31);
    public void update(Graphics g)
         this.paint(g);
    public void paint(Graphics g)
         width  = getWidth();
         height = getHeight()-4;
         Rectangle cl = g.getClipBounds();
         g.setColor(Color.pink);
         g.fillRect(cl.x,cl.y,cl.width,cl.height);
         g.setColor(color);
         g.fillOval(position,vposition,30,30);
         setCentre();
    public void setCentre()
         xCenter = position - 30/2;
         yCenter = vposition -30/2;
    public boolean didCollide(Animation x)
         distance = Math.sqrt( Math.pow( (xCenter- x.xCenter) ,2) + Math.pow((yCenter-x.yCenter) , 2) );
         if (distance <= 31) return true;
              else            return false;
    } Noah

  • Rather complicated (possibly!) threading/event handling problem...

    OK, so here's a good question to ask for my first post to this site!
    My current "project" is a GUI applet that does real-time interactions on a set of objects and user input. I'm using double buffering, event handling (from the keyboard) and multiple threads to handle the categories of "user input and graphics" and "world state updating." Here is a rough overview of how the program is layed out:
    // keyboard input status class
    class Keyboard extends KeyListener {
       static int[] code = new int[7];            // contains keycodes of interesting keys
       static boolean[] status = new boolean[7];     // status of keys (true=pressed)
       static boolean getStatus(int key) {
          return status[key];
       void keyPressed(KeyEvent e) {
          for(int i = 6; i >= 0; i--)
             if(code[i] == e.code)
                status[i] = true;
       void keyReleased(KeyEvent e) {
          for(int i = 6; i >= 0; i--)
             if(code[i] == e.code)
                status[i] = false;
    // main program applet
    class Program extends Applet implements Runnable {
       static Thread thread;      // main thread of applet
       static Image buffer;         // double buffer for offscreen rendering
       static boolean running;  // flag to indicate status of applet
       void init() {
          buffer = createImage(500, 500);
          // other initializations
       void destroy() {
          // other disposes
       void start() {
          running = true;
          thread = new Thread(this);
          thread.start();
          addKeyListener(new Keyboard());   // begin receiving input
       void stop() {
          running = false;
          if(thread != Thread.currentThread())
             thread.join();    // wait for thread to die before continuing
       void run() {
          double paintTimer = 0;   // timer to suspend painting to buffer until necessary
          double dt = 0;       // difference in time between loops
          while(running) {
             // update timing stuff (dt and paintTimer)
             // update world status
             paintTimer -= dt;      // to decrement painting timer
             if(paintTimer <= 0) {
                paintTimer = 1.0 / fps;    // reset paint timer based on current fps setting
                synchronized(syncObject) {
                   // paint world to buffer
                   repaint();
             Thread.yield();  // to yield time to painting and user input thread
       // this method is only called by the internal thread within the applet
       //  that is responsible for painting and event handling
       void paint(Graphics g) {
          // make sure painting to screen won't conflict with thread that's drawing on buffer!
          synchronized(syncObject) {
             g.drawImage(buffer, 0, 0, null);  // do double buffering...paint buffer to screen
    }So the end result is that it works fine some of the time, but every once in awhile I'll get these strange results where it'll seem as if the internal thread that handles graphics and input will get bogged down or stop responding normally, even with the Thread.yield() call from the main applet thread. I'll get results where the world will continue to be updated correctly, but the user input and onscreen rendering freeze in a particular state for a matter of seconds, and then it seems to regain control for a brief few milliseconds (hence I'll get a quick screen refresh and keyboard state change), and then it'll freeze again. Once this starts happening somewhere in the middle of execution, it continues to happen throughout that runtime session. Sometimes when I force-close the appletviewer I'll get weird native runtime exceptions that seem to occur within Sun's keyboard input manager.
    Almost always it'll run perfectly for many minutes, and then all of a sudden it'll start to freeze up. Every once in awhile it freezes almost immediately after startup. I've run some testcases on it and am pretty confident it has nothing to do with the synchronization or the fact that I create a new applet thread every time the applet is restarted dynamically. Is it something happening within the event thread of the applet that I'm not aware of? Or is it something wrong with the flow of my code? Thanks for any input or help you can give! I'll be happy to send more details if needed.
    Zach

    right before your repaint, putSystem.out.println("Is EDT? "+SwingUtilities.isEventDispatcherThread());if its printing false, then you need to do SwingUtilities.invokeLater( ... );
    and put GUI updating code in the invoke later.

Maybe you are looking for

  • Multiple transactions control in the same page

    I am using the Jdev11g 11.1.1.4 and ADF BC, I am quite new for Jdev11g, My question is I have a page, there are a af: form region and two af:table regions inside the same page. the 'master' is in af:form and two its 'details' are in either af:table.

  • Behaviors inconsistent when trimming - fix?

    Hi There, One thing that has been bugging me in Motion is the inconsistency between behaviors when you trim them. As an example, if you apply a Throw behavior to an object, then trim it, the object stops where you trim it, then stays there after the

  • Roll back the firmware.

    Just got the new express N version yesterday. I hooked it up wireless and it worked right off. Had access to the internet (slow access, but it was there) as well as iTunes to the stereo. Then I went back a little later to look at the manual settings.

  • Macbook Slowing Down

    Hi, I have been using my macbook for about 6 months now. So far I am very happy with the performance and def glad that I made the switch. About 2 weeks ago I began to notice a definite change in the speed and performance of my machine. Certain websit

  • To Stream or to download: That is the Question.

    Hi, Until recently i have only used my iTunes library for music only. I am toying with the idea of now using it for films and tv shows. So, present set up is that i have apple TV which is connected to my home computer on the same network. Q 1. If i b