Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4068622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:23:53+00:00 2026-05-20T16:23:53+00:00

I mentioned a small demo. in Setting up policies for an Applet embedded in

  • 0

I mentioned a small demo. in
Setting up policies for an Applet embedded in HTML
& an Iced Tea JRE user commented that the demo. failed
for them. They refused permission to the applet (thereby limiting it to the sand-box) & were supposed to see
the green colored ‘this applet is sand-boxed’ page. Instead the applet completely failed and they saw a ‘gray space’
where the applet should have been.

I am WAGing that it was attempting to instantiate a File object that is the difference. I.E.
The Sun/Oracle JRE will allow it without problem, only throwing a security exception
when the applet attempts to create the JFileChooser. OTOH the Iced Tea JRE does not allow the
File to be created.

As such, this code should fix that problem. It moves the creation/adding of the
JEditorPane and installation of 1st
an ‘all else fails’ message, then the green colored ‘sand-boxed’ page, to before the new File(..) call.

My question is. Does this code ‘work as advertised’ for users with an Iced Tea JRE?

To test it:

  1. Visit the applet at
    pscode.org/test/docload/applet-latest.html

  2. Refuse the digitally signed code. This is very important to create the right
    conditions to test the applet.

  3. Observe/report whether the applet loads the green colored
    sandbox.html. The sand-boxed
    document will represent ‘success’ at fixing the bug.

Also of interest (what little there might be) is the homepage for the
Demo of Defensive Loading of Trusted Applets, which links
to the applet page(s), each of the HTML files displayed in the applet, and a ZIP archive containing the
source of the code & HTML, and an Ant build.xml so you can ‘do this at home, kids’.

Here is the new code.

package org.pscode.eg.docload;

import java.awt.BorderLayout;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JFileChooser;

import java.net.URL;
import java.net.MalformedURLException;

import java.io.File;
import java.io.IOException;

import java.security.AccessControlException;

/** An applet to display documents that are JEditorPane compatible.
This applet loads in a defensive way in terms of the security environment,
in case the user has refused to accept the digitally signed code. */
public class DocumentLoader extends JApplet {
    JEditorPane document;

    @Override
    public void init() {
        System.out.println("init()");

        JPanel main = new JPanel();
        main.setLayout( new BorderLayout() );
        getContentPane().add(main);

        document = new JEditorPane("text/html",
            "<html><body><h1>Testing</h1><p>Testing security environment..");
        main.add( new JScrollPane(document), BorderLayout.CENTER );
        System.out.println("init(): entering 'try'");

        try {
            // set up the green 'sandboxed URL', as a precaution..
            URL sandboxed = new URL(getDocumentBase(), "sandbox.html");
            document.setPage( sandboxed );

            // It might seem odd that a sandboxed applet can /instantiate/
            // a File object, but until it goes to do anything with it, the
            // JVM considers it 'OK'.  Until we go to do anything with a
            // 'File' object, it is really just a filename.
            System.out.println("init(): instantiate file");
            File f = new File(".");
            System.out.println("init(): file instantiated, create file chooser");
            // Everything above here is possible for a sandboxed applet

            // *test* if this applet is sandboxed
            final JFileChooser jfc =
                new JFileChooser(f); // invokes security check
            jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            jfc.setMultiSelectionEnabled(false);

            System.out.println(
                "init(): file chooser created, " +
                "create/add 'Load Document' button");
            JButton button = new JButton("Load Document");
            button.addActionListener( new ActionListener(){
                    public void actionPerformed(ActionEvent ae) {
                        int result = jfc.showOpenDialog(
                            DocumentLoader.this);
                        if ( result==JFileChooser.APPROVE_OPTION ) {
                            File temp = jfc.getSelectedFile();
                            try {
                                URL page = temp.toURI().toURL();
                                document.setPage( page );
                            } catch(Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } );
            main.add( button, BorderLayout.SOUTH );

            // the applet is trusted, change to the red 'welcome page'
            URL trusted = new URL(getDocumentBase(), "trusted.html");
            document.setPage(trusted);
        } catch (MalformedURLException murle) {
            murle.printStackTrace();
            document.setText( murle.toString() );
        } catch (IOException ioe) {
            ioe.printStackTrace();
            document.setText( ioe.toString() );
        } catch (AccessControlException ace) {
            ace.printStackTrace();
            // document should already be showing sandbox.html
        }
    }

    @Override
    public void start() {
        System.out.println("start()");
    }

    @Override
    public void stop() {
        System.out.println("stop()");
    }

    @Override
    public void destroy() {
        System.out.println("destroy()");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:23:53+00:00Added an answer on May 20, 2026 at 4:23 pm

    Here is the output on java.stderr (one half of the equivalent of the Java console – the other half is java.stdout, which is empty in your case):

    net.sourceforge.jnlp.LaunchException: Fatal: Initialization Error: Could not initialize applet.
            at net.sourceforge.jnlp.Launcher.createApplet(Launcher.java:604)
            at net.sourceforge.jnlp.Launcher.getApplet(Launcher.java:548)
            at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:729)
    Caused by: net.sourceforge.jnlp.LaunchException: Fatal: Launch Error: Jars not verified.
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.checkTrustWithUser(JNLPClassLoader.java:467)
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeResources(JNLPClassLoader.java:410)
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:168)
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:249)
            at net.sourceforge.jnlp.Launcher.createApplet(Launcher.java:575)
            ... 2 more
    Caused by: 
    net.sourceforge.jnlp.LaunchException: Fatal: Launch Error: Jars not verified.
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.checkTrustWithUser(JNLPClassLoader.java:467)
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeResources(JNLPClassLoader.java:410)
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:168)
            at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:249)
            at net.sourceforge.jnlp.Launcher.createApplet(Launcher.java:575)
            at net.sourceforge.jnlp.Launcher.getApplet(Launcher.java:548)
            at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:729)
    java.lang.NullPointerException
            at net.sourceforge.jnlp.NetxPanel.runLoader(NetxPanel.java:99)
            at sun.applet.AppletPanel.run(AppletPanel.java:380)
            at java.lang.Thread.run(Thread.java:636)
    java.lang.NullPointerException
            at sun.applet.AppletPanel.run(AppletPanel.java:430)
            at java.lang.Thread.run(Thread.java:636)
    java.lang.Exception: Applet initialization timeout
            at sun.applet.PluginAppletViewer.handleMessage(PluginAppletViewer.java:637)
            at sun.applet.PluginStreamHandler.handleMessage(PluginStreamHandler.java:270)
            at sun.applet.PluginMessageHandlerWorker.run(PluginMessageHandlerWorker.java:82)
    java.lang.RuntimeException: Failed to handle message: handle 60822154 for instance 2
            at sun.applet.PluginAppletViewer.handleMessage(PluginAppletViewer.java:660)
            at sun.applet.PluginStreamHandler.handleMessage(PluginStreamHandler.java:270)
            at sun.applet.PluginMessageHandlerWorker.run(PluginMessageHandlerWorker.java:82)
    Caused by: java.lang.Exception: Applet initialization timeout
            at sun.applet.PluginAppletViewer.handleMessage(PluginAppletViewer.java:637)
            ... 2 more
    

    So, it looks like your applet code is not even loaded if I press Cancel in the dialog box.

    confirmation dialog

    I think there is nothing you can do here from the Java side – maybe using another signing procedure or starting the applet by JNLP would help. Or filing a bug report on IcedTea.


    To demonstrate this, I created a real simple applet by omitting everything critical from your applet:

    package org.pscode.eg.docload;
    
    import java.awt.FlowLayout;
    import javax.swing.*;
    
    public class Example extends JApplet {
    
    
        JLabel label;
    
        public void init()
        {
            System.out.println("init()");
            SwingUtilities.invokeLater(new Runnable(){public void run() {
                label = new JLabel("inited.");
                getContentPane().setLayout(new FlowLayout());
                getContentPane().add(label);
            }});
        }
    
        @Override
        public void start() {
            System.out.println("start()");
            label.setText("started.");
        }
    
        @Override
        public void stop() {
            System.out.println("stop()");
            label.setText("stopped.");
        }
    
        @Override
        public void destroy() {
            System.out.println("destroy()");
            label.setText("destroyed.");
        }
    }
    

    I compiled this and modified your HTML file to use this instead, and it gives totally the same symptoms.

    It seems IcedTea has redefined what to do when the user presses cancel. To be fair, the buttons in the dialog box are “Run” and “Cancel”, not “Run with all permissions” and “Run sandboxed”.

    (In Sun’s dialog there are the same buttons, but in effect they mean something else than asked.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting up a very small MySQL database that stores, first name, last
I have a small demo executable wrote in C++ that depends only on one
my friend mentioned to me that since i was only using update panels on
As I mentioned here , I'm trying to generate HTML from an ASPX page
UPDATE: I should have mentioned in the original post that I want to learn
Assume that the following code is being executed by 10 threads. pthread_mutex_lock(&lock) Some trivial
Jeff has mentioned in the past that dealing directly with the advertiser is a
I was going through a Java tutorial where it was mentioned that actual multithreading
I have a small application that uses the same API as the powerscript examples
We've developed a small app using play!, and it runs standalone on a user's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.