Applet DB Exception

I have tried to connect to Microsoft SQL server 7.0 on my server using Java applet, rather it threw an exception as stated below
java.security.AccessControlException:accessdenied(java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
can any one help me out please.

I got that exception too. Then I tried to run my program as an application, and worked.
Applets have security restrictions. You must allow them to make external conections.

Similar Messages

  • Applet socket exception

    An applet connects to a socket on the server and works fine. It establishes Object input and Output streams.
    When the web page is closed the server catchs a SocketException which is thrown due to the readObject() method being called on an ObjectInputStream which obviously no longer exists.
    Is there any other way of telling the server that the applet has terminated or due i just use this exception to clean things up (i.e. close the streams and coonection and de-reference the thread).
    thanks.

    The applet could send a message to the server in the method Applet#stop()

  • HELP!! - Local Applet Security Exception

    How do I set the Security correctly so I can use appletviewer, and not get this message?
    C:\temp\TestPhoto>appletviewer PhotoUploader.html
    a java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272) at Java.security.AccessController.checkPermission(AccessController.java: 399)at java.lang.SecurityManager.checkPermission(SecurityManager.java:545) at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1278) at java.lang.System.getProperty(System.java:560) at Javax.swing.filechooser.FileSystemView.getHomeDirectory(FileSystemView.java:110) at javax.swing.JFileChooser.setCurrentDirectory(JFileChooser.java:443) at javax.swing.JFileChooser.<init>(JFileChooser.java:308)
    at javax.swing.JFileChooser.<init>(JFileChooser.java:266) at TestPhoto.UploadFile.initComponents (UploadFile.java:39) at TestPhoto.UploadFile.<init>(UploadFile.java:27) at TestPhoto.PhotoUploader.initMainWindow(PhotoUploader.java:86) at TestPhoto.PhotoUploader.<init>(PhotoUploader.java:31)
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java:237)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:586) at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
    at sun.applet.AppletPanel.run(AppletPanel.java:293)
    at java.lang.Thread.run(Thread.java:484)

    nevermind, found it. For those with same problem, open policy tool and add permission, set permissions to all, and hit ok

  • Applet run exception

    hi,
    friends. i am a new java-er. i run my applet on set operation, the program compiled, but the applet fell in trouble when it is running. my screen shows as:
    A:\>appletviewer SetApplet.html
    java.lang.NullPointerException
    at SetApplet.init(SetApplet.java:20)
    at sun.applet.AppletPanel.run(AppletPanel.java:287)
    at java.lang.Thread.run(Thread.java:474)
    i don't know how to deal with this problem.
    PLEASE HELP!
    Thank you very much!

    hi,
    thank you for your help. here is my code, the 20th line is on " Panel p = new Panel();" and the nearby code as following
    Panel p = new Panel();
         p.add(set1Selector);
         p.add(set2Selector);
         add("North", p);     // Lists
         set1List = new List();                    set1List.setBackground(Color.white);     
         set2List = new List();
    here is the whole code:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
         public class SetApplet extends Applet implements                ActionListener,     ItemListener {
         public void init() {
              set1 = new Set();
              set2 = new Set();          // Components          setLayout(new BorderLayout());
                             // Checkboxes               set1Selector = new Checkbox("Set 1");               //13
         set1Selector.addItemListener(this);
         set2Selector = new Checkbox("Set 2");
         set2Selector.addItemListener(this);
         selectorGroup = new CheckboxGroup();
         set1Selector.setCheckboxGroup(selectorGroup);
         set2Selector.setCheckboxGroup(selectorGroup);
         Panel p = new Panel();
         p.add(set1Selector);
         p.add(set2Selector);
         add("North", p);     // Lists
         set1List = new List();                              set1List.setBackground(Color.white);     
         set2List = new List();
         set2List.setBackground(Color.white);
         resultList = new List();
         resultList.setBackground(Color.white);
         p = new Panel();
         p.add(new Label("Set1"));
         p.add(set1List);
         p.add(new Label("Set2"));               //33
         p.add(set2List);
         p.add(new Label("Result"));
         p.add(resultList);
         add("Center", p);     // Buttons
         add = new Button("Add:");
         add.addActionListener(this);
         value = new TextField(5);
         clear = new Button("Clear");
         clear.addActionListener(this);
         union = new Button("Union");
         union.addActionListener(this);
         intersect = new Button("Intersect");
         intersect.addActionListener(this);
         p = new Panel();
         p.add(add);
         p.add(value);
         p.add(clear);
         p.add(union);
         p.add(intersect);
         add("South", p);               //53
              // Set active check box                         
         selectorGroup.setSelectedCheckbox(set1Selector);
         setActive();
              // Handles action events generated by the buttons          
         public void actionPerformed(ActionEvent ae) {
         if (ae.getSource() == add) {     
              addElement();               
              repaint();          
         else if (ae.getSource() == union)
              loadResult(set1.union(set2));
         else if (ae.getSource() == intersect)
              loadResult(set1.intersection(set2));
         else if (ae.getSource() == clear) {
              activeSet.removeAllElements();
              activeList.removeAll();
         // Handles item events generated by the check boxes//80
         public void itemStateChanged(ItemEvent ie) {
              setActive();
         private void addElement() {
         int i = Integer.parseInt(value.getText());               activeSet.addElement(new Integer(i));                    activeList.addItem(Integer.toString(i));
         private void setActive() {
              List newActiveList;          
         if (selectorGroup.getSelectedCheckbox() == set1Selector) {               activeList = set1List;
              activeSet = set1;
         else {
         activeList = set2List;
         activeSet = set2;                    //100
         private void loadResult(Set resultSet) {
         resultList.removeAll();                              Enumeration e = resultSet.elements();          
         while (e.hasMoreElements())          
              resultList.addItem(e.nextElement().toString());
         repaint();                                   }                                             Button add, union, intersect, clear;                    List set1List, set2List, activeList, resultList;               Checkbox set1Selector, set2Selector;                    CheckboxGroup selectorGroup;                         TextField value;                              Set set1, set2, activeSet;                    
    }                                   //117
    Could any one help me out ! Thanks a lot!

  • Sending a file from Applet to servlet HELP me Please

    Sorry, i have the problem this is my code Applet & Servlet but it seems working asynchronously if you have some ideas please reply me i send bytes on outputstream but the inputstream of servlet receive nothing bytes but write my system.out.print on screen server:
    Applet:
    URL servletURL = new URL(codebase, "/InviaFile/servlet/Ricevi");
    HttpURLConnection urlConnection = (HttpURLConnection) servletURL.openConnection();
    urlConnection.setRequestMethod("POST");
    urlConnection.setUseCaches(false);
    urlConnection.setDoOutput(true);
    urlConnection.setDoInput(true);
    urlConnection.setAllowUserInteraction(false);
    urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
    urlConnection.setRequestProperty("Content-length", String.valueOf(100));
    urlConnection.connect();
    if(urlConnection.HTTP_BAD_REQUEST == HttpURLConnection.HTTP_BAD_REQUEST){
    /*System.out.println("Cattiva Richiesta: "+urlConnection.getContentEncoding());
    System.out.println("Tipo di metodo: "+urlConnection.getRequestMethod());
    System.out.println("Tipo di Risposta: "+urlConnection.getResponseCode());
    System.out.println("Tipo di messaggio: "+urlConnection.getResponseMessage());
    System.out.println("Tipo di contenuto: "+urlConnection.getContentType());
    System.out.println("Tipo di lunghezza contenuto: "+urlConnection.getContentLength());
    System.out.println("Tipo di doinput: "+urlConnection.getDoInput());
    System.out.println("Tipo di doouput: "+urlConnection.getDoOutput());
    System.out.println("Tipo di URL: "+urlConnection.getURL());
    System.out.println("Tipo di propriet� richiesta: "+urlConnection.getRequestProperty("Content-Type"));
    System.out.println("Entra if");
    DataOutputStream dout = new DataOutputStream(urlConnection.getOutputStream());
    InputStream is = urlConnection.getInputStream();
    if(ritornaFile("C:/Ms.tif", dout))System.out.println("Finita lettura");
    dout.close();
    urlConnection.disconnect();
    System.out.println("Fine Applet");
    }catch(Exception e) { System.err.println(e.getMessage());e.printStackTrace();}
    public boolean ritornaFile(String file, OutputStream ots)throws Exception{
    FileInputStream f = null;
    try{
    f = new FileInputStream(file);
    byte[] buf = new byte[4 * 1024];
    int byteLetti;
    while((byteLetti = f.read()) != -1){ots.writeByte(buf, 0, byteLetti);ots.flush();
    while((byteLetti = f.read()) != -1){ots.write(byteLetti);ots.flush();
    System.out.println("byteLetti= "+byteLetti);
    return true;
    }catch(Exception ex){
    System.err.println(ex.getMessage());
    return false;
    }finally{
    if(f != null)f.close();
    Servlet:
    HttpSession ses = request.getSession(true);
    System.out.println("Passa servlet "+request.getMethod());
    System.out.println("Passa servlet "+ses.getId());
    ServletInputStream servletinputstream = request.getInputStream();
    DataInputStream dis = new DataInputStream(request.getInputStream());
    int c = dis.available();
    System.out.println("c="+c);
    //ServletOutputStream servletoutputstream
    //response.getOutputStream();
    response.setContentType("application/octet-stream");
    System.out.println("URI= "+request.getRequestURI());
    System.out.println("pathTranslated: "+request.getPathTranslated());
    System.out.println("RemoteUser: "+request.getRemoteUser());
    System.out.println("UserInRole: "+String.valueOf(request.isUserInRole("")));
    System.out.println("pathInfo: "+request.getPathInfo());
    System.out.println("Protocollo: "+request.getProtocol());
    System.out.println("RemoteAddr:"+request.getRemoteAddr());
    System.out.println("RemoteHost:"+request.getRemoteHost());
    System.out.println("SessionID:"+request.getRequestedSessionId());
    System.out.println("Schema:"+request.getScheme());
    System.out.println("SeesionValido:"+String.valueOf(request.isRequestedSessionIdValid()));
    System.out.println("FromURL:"+String.valueOf(request.isRequestedSessionIdFromURL()));
    int i = request.getContentLength();
    System.out.println("i: "+i);
    ritornaFile(servletinputstream, "C:"+File.separator+"Pluto.tif");
    System.out.println("GetMimeType= "+getServletContext().getMimeType("Ms.tif"));
    InputStream is = request.getInputStream();
    int in = is.available();
    System.out.println("Legge dallo stream in="+in);
    DataInputStream diss = new DataInputStream(servletinputstream);
    int ins = diss.read();
    System.out.println("Legge dallo stream ins="+ins);
    int disins = diss.available();
    System.out.println("Legge dallo stream disins="+disins);
    is.close();
    System.out.println("Fine Servlet");
    catch(Exception exception) {
    System.out.println("IOException occured in the Server: " + exception.getMessage());exception.printStackTrace();
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    public void ritornaFile(InputStream its, String fileDest )throws Exception{
    FileOutputStream f = null;
    try{
    f = new FileOutputStream(fileDest);
    byte[] buf = new byte[2 * 1024];
    int byteLetti;
    while((byteLetti = its.read()) != -1){
    f.write(buf, 0, byteLetti);
    f.flush();
    System.out.println("Byteletti="+byteLetti);
    }catch(Exception ex){
    System.err.println(ex.getMessage());
    }finally{
    if(f != null)f.close();

    Hi all,
    Can anyone help me.I am trying to send an audio file from a applet to servlet with HTTP method(no raw sockets), also the servlet shld be able to save the file on the server.Any suggestions welcome.USing audiostream class from javax.sound.sampled.
    The part of applet code which calls servlet is :
    URL url = new URL("http://" + host + "/" + context + "/servlet/UserUpdateWorkLogAudio?userid=" + userId.replace(' ', '+') + "&FileName=" + filename.replace(' ', '+'));
    URLConnection myConnection = url.openConnection();
    myConnection.setUseCaches(false);
    myConnection.setDoOutput(true);
    urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
    myConnection.connect();
    out = new BufferedOutputStream(myConnection.getOutputStream());
    AudioSystem.write(audioInputStream, fileType,out); // IS THIS RIGHT APPROACH?
    ************************end of applet code**********************
    ************************servlet code******************************
    try
    {BufferedInputStream in = new BufferedInputStream(request.getInputStream());
    ????????What code shld i write here to get the audio file stream
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(filename));
    *********************************************end***********************
    Thanks
    Joe.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • OS X 10.5.6, Safari 3.2.1 hangs when second applet loaded is signed applet

    Dear Forum,
    I've been investigating a customer's problem. She is trying to use our
    VoIP applet, but it continuously freezes Safari when the Trust dialog shows.
    A "Force Quit" is necessary.
    I managed to reproduce the problem consistently on
    - PowerMac7 OS X 10.5.6 (Build 9G55)
    - Architecture: ppc
    - Safari 3.2.1 (5525.27.1)
    - JVM 1.5.0_16 from Apple
    The problem is persistent when:
    - the signed applet is loaded as second applet in the browser
    - the signed applet is cached by the JVM
    Our customer uses:
    - Mac Book ProOS X 10.5.6
    - Safari 3.2.1
    - JVM 1.5.0_16 from Apple
    This problem does not occur on:
    - Mac OS X 10.4.11 (Mac Powerbook G4)
    - Safari 3.2.1 (4525.27.1)
    - JVM 1.5.0_16 from Apple
    and not on:
    - MacBook Air, OS X 10.5.6, 1.6 Ghz Intel core 2 duo
    - Safari Version 3.2.1 (5525.27.1)
    - JVM 1.5.0_16 from Apple
    Steps to reproduce the problem:
    Launch Safari.
    In (first) page/tab go to
    http://www.javatester.org/version.html
    (this uses a non signed applet)
    Open a second tab. Here go to:
    http://ukapi.phonefromhere.com/talk/vtop2.xsql?key=01612884242
    This is a signed applet that will ring our office over VoIP.
    Click the "Trust" button (signed by PhoneFromHere).
    As long as this applet isn't cached by the JVM this will work, so
    the first time you will succeed.
    Now Quit Safari (not "just" close all Safari windows, but a "real" quit) and repeat the exercise.
    The second (and next) time this will fail (only if the signed applet is loaded as second, so the order is important)! This keeps failing until I go (back) to the Java Preference window (via Finder) and explicitly delete the cached files.
    The URL will work when loaded first (cached or not).
    Some diagnostics, that might help:
    I configured the Java Preference window to "enable Logging, Tracing and Show applet livecycle exceptions".
    When the applet fails to load (and Safari freezes/hangs), the last few records of the plugin150.log are:
    <message>basic: Loading http://ukapi.phonefromhere.com/talk/lib/pfh.jar from cache
    <message>basic: Reading cached JAR file from JRE 1.5 release
    <message>basic: Certificates for http://ukapi.phonefromhere.com/talk/lib/pfh.jar is read from JAR cache
    <message>security: Loading certificates from Deployment session certificate store
    <message>security: Loaded certificates from Deployment session certificate store
    <message>security: Checking if certificate is in Deployment session certificate store
    (and then nothing)
    whereas when it succeeds to load, as soon as I click the "Trust" button, it's say:
    <message>security: User has granted the priviledges to the code for this session only
    The Report is a bit too long to port, I'll include the same text above when sending it.
    Model: PowerMac7,2, BootROM 5.1.3f0, 2 processors, PowerPC 970 (2.2), 1.8 GHz, 2 GB
    To cut a long story short? Is this a know bug (I couldn't find anything, but you never know)? Does anyone have any ideas how to fix this?
    Thanks, Birgit

    I have the same issue now after downgrading my Flash plugin. I downgraded from 10 to 9 latest because I like using Camino and for some reason Flash 10 doesn't play nice with Camino. But all of a sudden as I use Camino 2b2 for everyday and Safari 3.2 for banking and such, the browser hangs requiring a forced quit when I close it. I've re-installed the browser twice now with all the previous folders, and preferences erased and caches emptied. I even when to re-installing 10.5.6 and it still crashes, it's odd. Maybe 10.5.7 will address this.

  • Java Applets not working in New Versions of Java

    I have developed a chat program using Applets(developed using jdk1.2),using a Server.Everything is perfectly working.Now,On my client machine i installed jdk1.4, and when i try to download the same applet it is giving Applet ClassNotFound Exception?.
    I have just set the class path to jdk1.4.And trying to call the applet from a browser.
    IS there any changes in writing the applets using the new version of Java?
    Kindly let me know.
    Thanks & Regards.,
    Naveen Kumar

    Sorry can't use em anymore.
    ah, ... perhaps not.
    What class is not found?

  • JAVA Applets is CRAP

    Unless there is some1 on the planet that knows how to fix a simple
    problem:
    It has nothing to do with Java code. The problem is with the
    JRE and IE. If you use the HTMLCONVERTER that comes with the SDK
    it converts you applet tags in your html file to object tags. Then
    it works fine. But that does not help the solution. It must work
    with only the applet tags in your html code. I ahve been struggling
    for two weeks now and can't get it working. If you run the demo
    applets that comes with the sdk you'll see it also doesn't work
    unless you apply the HTMLCONVERTER to it. So I AM FEDUP WITH THIS
    CRAP !!! NOBODY SEEM TO KNOW HOW TO FIX THIS &%#@*& PROBLEM !!!
    I HAVE POSTED MESSAGES IN 5 OTHER FORUMS FROM DIFFERENT WEBSITES and
    the best answer I get is to install the latest Java plugin.
    WELL THAT DOESN'T WORK !!!!!!!!!!!
    Java APPLETS SUCK BIGTIME AND I'M FEDUP STRUGGLING !!!
    I suppose thats what you get with "free" software.
    I have tried this problem with IE6 and IE5 on WIN98SE on 3 different PC's. No luck. Sorry guys..... the only solution is to give up you
    programming career.
    from: very fedup beginner programmer (or anti-Java programmer)

    LOL, whatcha talking about?
    Don't learn Java, your problem. Java is slowly becoming the next language, the c++ of today.
    The features are too great to pass up, really:
    portable code,
    cleaner language (though at the expense of some features),
    security (eg. untrusted code in applets),
    USEFUL exception errors
    Trust me, it SUCKS even more in c++ to get seg faults or a crash without any message, and then you have to look for out-of-bounds indexes, % by 0, etc. Java speeds up programming time by a LOT.

  • Socket communication between applet and an AP on simulastor

    Hi!
    I implemented my system under Server/Client model.
    The server is running in a Set-Top-Box simulator, which
    creates a ServerSocket on port 9190.
    The client is an applet and using the following codes to connect to server:
    ==========================================
    Socket socket = new Socket("127.0.0.1", 9190)
    InputStream in = socket.getInputStream();
    OutputStream out = socket.getOutputStream();
    ==========================================
    When I start the applet, no exceptions are thrown,
    and objects socket, in and out are not null.
    But when I was trying to send a string to server,
    ==========================================
    out.write("a string".getBytes());
    ==========================================
    nothing happened. Server didn't get anything.
    What's wrong? How can I solve this?

    First of all "nothing happend" is something you tell the DELL helpdesk.
    This is a developer forum.
    My guess is you are using somthing of a in.readLine() on the server and since the
    client doesn't sent a linebreak it will hang there.
    Or the client gets an AccessControlException that you silently catch and therefore get
    no exception. Allthough the InputStream would be declared in the try block (according
    to posted code) and can not be checked for beeing null in the catch (out of scope).
    Here is some sample code of client and server, try to implement the run method in
    your client and run both appTest and applet on the local machine (http://127.0.0.1).
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class appTest implements Runnable {
         public appTest() {
              new listner().start();
              new Thread(this).start();
         // main program
         public static void main(String argv[]) throws Exception {
              new appTest();
         public void run() {
              // the client
              try {
                   Socket s = new Socket("127.0.0.1", 9190);
                   // if multiple messages are to be sent and received
                   // this is where you start a new thread
                   byte b[];
                   OutputStream out = s.getOutputStream();
                   InputStream in = s.getInputStream();
                   String message = "hello from client";
                   int messageLength = message.getBytes().length;
                   // writing the length of the message
                   out.write(new Integer(messageLength).byteValue());
                   b = message.getBytes();
                   // writing the message
                   out.write(b);
                   // reading the length of the message and setting the byte array to
                   // it
                   b = new byte[in.read()];
                   in.read(b);
                   // receiving the message
                   System.out
                             .println("received massage from server: " + new String(b));
                   out.close();
                   in.close();
              } catch (Exception e) {
                   e.printStackTrace();
         class listner extends Thread {
              public void run() {
                   try {
                        ServerSocket srv = new ServerSocket(9190);
                        while (true) {
                             try {
                                  System.out.println("before accepting a client");
                                  Socket s = srv.accept();
                                  System.out.println("after accepting a client");
                                  // if multiple messages are to be sent and received
                                  // this is where you start a new thread
                                  byte b[];
                                  OutputStream out = s.getOutputStream();
                                  InputStream in = s.getInputStream();
                                  // reading the length of the message and setting the
                                  // byte array to
                                  // it
                                  b = new byte[in.read()];
                                  in.read(b);
                                  // receiving the message
                                  System.out.println("received massage from client:"
                                            + new String(b));
                                  System.out.println("sending message from server:");
                                  String message = "hello from server";
                                  int messageLength = message.getBytes().length;
                                  // writing the length of the message
                                  out.write(new Integer(messageLength).byteValue());
                                  b = message.getBytes();
                                  // writing the message
                                  out.write(b);
                                  out.close();
                                  in.close();
                             } catch (Exception ex) {
                                  ex.printStackTrace();
                   } catch (Exception e) {
                        e.printStackTrace();
    }

  • Signed Java Applet

    0 down vote favorite
    I have written an applet with Netbeans. When I click on Clean and Build then Netbean create a jar file "Test.jar" and also another folder called lib in the same directory. I've signed the Test.jar. Basically this applet upload files to server with FTP. So when Applet loads into browser then I am able to select files but when I click on upload then it stops. So my question is:
    1. Have I also need to sign all dependent jar files?
    2. My directory structure is as follow:
    C:\AppletPage.html C:\Test.jar C:\lib
    and code in html file is as follow
    <applet code="UploadGUI.class"
    archive="test.jar"
    width=400 height=400></applet>Please advice me where am I wrong?
    Thanks in Advance

    Shahid_Hanif wrote:
    0 down vote favoriteHuhh?
    I have written an applet with Netbeans. ..My condolences.
    ..lWhen I click on Clean and Build then Netbean create a jar file "Test.jar" and also another folder called lib in the same directory. I've signed the Test.jar. Basically this applet upload files to server with FTP. ..If you deploy the applet in a Plug-In 2 architecture JRE and launch it using Java Web Start - it can be sand-boxed.
    ..So when Applet loads into browser then I am able to select files but when I click on upload then it stops. .. What messages appear in the Java Console? Does the code of the applet [swallow exceptions|http://pscode.org/javafaq.html#stacktrace] (<- link)?
    ..So my question is:
    1. Have I also need to sign all dependent jar files?What dependent Jars? The applet element shown lists only one Jar in the archive attribute.
    2. My directory structure is as follow:
    C:\AppletPage.html C:\Test.jar C:\libWhat (if anything) is in 'lib'?
    Edit 1:
    Also posted to [http://stackoverflow.com/questions/3740006/java-applet-sign]
    Edited by: AndrewThompson64 on Sep 18, 2010 1:07 PM

  • Tracking applet instances

    I have an applet, and I want to support multiple instances of the applet running in the same browser.
    This is easy: just make sure that the applet object is encapsulated properly - no ugly globals which aren't shareable.
    However, the applet needs to use classes which create Threads and then perform callbacks into the main applet code. These callbacks are unfortunately static methods, even though the different applet instances need to handle them differently. The obvious solution would be to modify these classes, but they are binary only.
    I had this working for Netscape 4 and Internet Explorer using Microsoft's JVM, by calling...
    Thread.currentThread ().getThreadGroup ()...and maintaining a table mapping this object reference to a context object which could contain the information needed by the callback routine. This works because both JVMs create a separate ThreadGroup for each applet instance.
    Sadly, it seems the Sun Java Plugin used by Netscape 6, most other browsers, and increasingly many installations of IE, puts all applet threads in the same thread group, no matter which applet instance they belong to.
    Have a look at http://www.omniconsumerproducts.com/~martin/applet_test/test.html to see the problem. The source is in the same directory on the server.
    Does anyone have any other solutions? I need to be able to get something globally that is unique to an Applet instance. I tried ClassLoader but all the browsers I tried use the same ClassLoader for different instances of the same applet. (Except for Netscape 4 if you shift-reload, but that's another story.)
    The optimal solution would be if Applets could create their own child ThreadGroups, but they can't for security reasons (even though child ThreadGroups inherit all the restrictions of the parent).
    Any ideas?
    Martin

    Are the threads created by the library doing anything time consuming? If not, then you can make sure that the library function that create the threads will not be called before the previous thread created by the function ends. Here is some pseudo code to show the idea. Since this is a design hack, it may not fit in your case though.
    I tested the Mutex class, so the remaining code may have some error. Howerver, it should make the idea clear.
    Lets assume you call a library function with two Object argument and the library calls back a static method someCallBackMethod in a new thread.
    from your applet Foo you will do something like this,
    class Foo extends Applet {
    static LibraryAdapter la = new LibraryAdapter();
    public void someMethod() {
    la.call(this, someObject1, someObject2)
    public static someCallBackMethod() {
    Foo foo = la.getActive()
    foo.doneWithActive();
    }//Foo ends
    class LibraryAdapter implements Runnable {
    Queue queue = some thread safe queue implementation
    private Mutex fetch = new Mutex();
    private Mutex queueMutex = new Mutex();
    public LibraryAdapter() {
    new Thread(this).start();
    public void call(Foo caller, Object arg1, Object arg2) {
    queue.enqueue(new InvokationData(caller, arg1, arg2));
    queueMutex.notifyX();
    public Foo getActive() {
    return queue.front().caller;
    public void doneWithActive() {
    queue.dequeue();
    fetch.notifyX();
    private class InvokationData{
    Foo caller;
    Object arg1;
    Object arg2;
    ... constructor
    public void run() {
    while(true) {
    fetch.waitX();
    queueMutex.waitX();
    InvokationData data = (InvocationData)queue.front()
    ... interact with library with data
    }//main loop ends
    }//run ends
    }//top level class ends
    public class Mutex{
    private Object m = new Object();
    private int wtc = 0;//waiting notify call counter
    private int encc = 0;//extra notify call counter
    public void waitX() throws InterruptedException{
    synchronized(m){
    if(encc > 0){
    encc--;
    }else {
    wtc++;
    try{
    m.wait();
    }catch(InterruptedException ex){
    wtc--;
    throw ex;
    }//else ends
    }//sync ends
    }//waitX() ends
    public void notifyX() {
    synchronized(m){
    if(wtc == 0){
    encc++;
    }else{
    m.notify();
    wtc--;
    }//sync ends
    }//notifX ends
    }//Mutex ends

  • Why the IE cannot open the Applet build by Swing

    Halo, i build a GUI inside an Applet, by using the Java Swing. althoug i have
    installed the Java plug in, and use the HTML converter, but when i try to use the internet explorer to open this applet, the exception is thrown, and it said the
    "Start: didnt initialize the applet" in the IE window.
    and this is the error message shown in the the Java Console:
    java.security.AccessControlException: access denied (java.io.FilePermission anny.gif read)
         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.checkRead(Unknown Source)
         at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
         at sun.awt.SunToolkit.getImage(Unknown Source)
         at javax.swing.ImageIcon.<init>(Unknown Source)
         at javax.swing.ImageIcon.<init>(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Anyone can help me in this problem? thank you very much

    the image saved with the class file of the applet, and this applet i will
    paste in the server, it is funny when i cut all the codes about the imageicons,
    then the IE can load the applet and show it ,
    and now i use the xx = new ImageIcon("xxx.gif"); to construct an imageicon in the java code of that applet,but it got the problem
    i want to konw whether can use xxx = new ImageIcon(url) will help me to solve this problem, and if it can, how format the url is, for example, the IP of my server is 172.20.54.152, and the image anny.jpg saved in C:/Javaprogram,
    can u tell me what is the solution.
    Thank you very much

  • Obtaining a resource statically in an applet

    Hey guys,
    I have an applet where a number of image files are stored statically in resource classes. However, they are retrieved by file name, which is a problem when trying to put it on the web. Example below:
    public static Image First= Toolkit.getDefaultToolkit().getImage("Resources/1/First.png");Any suggestions?

    Sure thing:
    An applet:
    import java.applet.Applet;
    import java.awt.Graphics;
    public class app extends Applet {
         public void paint (final Graphics g)
              g.drawImage(resource.x, 0, 0, this);
    }and a resource class holding a static image:
    import java.awt.Image;
    import java.awt.Toolkit;
    public class resource {
    public static Image x = Toolkit.getDefaultToolkit().getImage("IMG.gif");
    }Compiling and dumping the 2 as well as the image in a JAR file, then running the applet yields:
    Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
         at app.paint(app.java:8)
         at sun.awt.RepaintArea.paintComponent(Unknown Source)
         at sun.awt.RepaintArea.paint(Unknown Source)
         at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.security.AccessControlException: access denied (java.io.FilePermission IMG.gif read)
         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.checkRead(Unknown Source)
         at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
         at sun.awt.SunToolkit.getImage(Unknown Source)
         at resource.<clinit>(resource.java:6)
         ... 14 moreAny help is appreciated, guys.

  • Signed Applet not loading.

    Hi all, Im currently using an applet that is signed. It works on java 1.4 but not on 1.6. Im not sure on hwo to make it work with 1.6 i tried the java control panel stuffs and the clearing my browser history stuffs too.
    I get this error from the console.
    Security manager class: sun.plugin2.applet.Applet2SecurityManager
    Exception in thread "Thread-29" java.security.AccessControlException: access denied (java.io.FilePermission C:\My Documents read)
         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.checkRead(Unknown Source)
         at java.io.File.exists(Unknown Source)
         at java.io.Win32FileSystem.canonicalize(Unknown Source)
         at java.io.File.getCanonicalPath(Unknown Source)
         at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Unknown Source)
         at sun.awt.shell.Win32ShellFolderManager2.getPersonal(Unknown Source)
         at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
         at sun.awt.shell.ShellFolder.get(Unknown Source)
         at javax.swing.filechooser.FileSystemView.getDefaultDirectory(Unknown Source)
         at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
         at javax.swing.JFileChooser.<init>(Unknown Source)
         at javax.swing.JFileChooser.<init>(Unknown Source)
         at com.sdrc._metaphase.wcc.osservices.OSSFileChooserDialog.createGUI(OSSFileChooserDialog.java:99)
         at com.sdrc._metaphase.wcc.osservices.OSSFileChooserDialog.init(OSSFileChooserDialog.java:125)
         at com.sdrc._metaphase.wcc.dmapplets.DMFileChooserApplet$DMFileChooserAppletRunnable.doRun(DMFileChooserApplet.java:206)
         at com.sdrc._metaphase.wcc.pluginsecurity.PSAppletRunnable.run(PSAppletRunnable.java:43)
         at java.lang.Thread.run(Unknown Source)
    Please let me know on how to rectify this problem. Thanks,

    I am experiencing the same problem - I notice it does not happen on OS9.2 using IE but appears a problem on all browsers on OSX
    Apple gave me the following reply.....
    Re: Bug ID# 3268633: cannot load applet class under https connection
    Hello Andrew,
    Thank you for bringing this problem to our attention. We have received feedback
    from engineering on your
    reported issue.
    Please know that to get Java to recognize the certificate you will need to do
    one of two things, depending
    on which VM you are using. Since you want it to work with Internet Explorer, we
    will assume Java 1.3.1.
    In Java 1.3.1 you'll need to add the certificate to
    /Library/Java/Home/lib/security/cacerts using
    /usr/bin/keytool to import the certificate into the certificate database.
    In Java 1.4.1 you should be able to just add the certificate to the keychain
    using certtool. For more
    details on how to do this, please refer to the information found at
    <http://java.sun.com/j2se/1.4.1/docs/tooldocs/solaris/keytool.html>. After
    doing so, if you should require
    further help from Apple in resolving this issue, we recommend that you request
    assistance from Developer
    Technical Support. This must be done by filing a Technical Support Incident.
    So I am supposed to tell every Mac user to do the above am I?!!!

  • Applet that will browse for files!

    I have used applications in the past where you want to open a file in that application, such as a word document in a word processor. Is there that sort of facility available to Java. Say that I write an applet that excepts text in a box and the text could be found on a text file on the user's hard drive. Is there code that would open a dialog box where the user could navigate to the appropriate text file? Any code, web resource or suggestions very gratefuly received. Thanks, Dave.

    Addendum ;)
    You can actually sign applets with you own certficate. This will let your applet get the autorization to access the file sistem. People using that applet will just have to trust that selfmade certificate, since it won't be officially trusted. It's kind of a workaround so to speak, but it lets you provide an applet with no restrictions. And for free, no fee.
    There's a thread on this forum explaing step by step how to proceed to sign an applet using a self-signed certificate.
    Applet vs Application: Deployment and version control are very easy and require little effort while redeploying a java appliation to a lot of people is a serious issue, unless you provide the required "update" functionality by yourself (code it ;(
    Another option would be using Java Webstart, but there again you would probably have to sign the application to get the necessary functionality (Security Managager again.)
    Patrick

Maybe you are looking for

  • Changing the date on a photo?

    So I have this album from a trip that has, oh, 600 photos in it. What I didn't realize at the time was that the imprint date on the camera was like 2 1/2 years off. For proper organization, I'd like to change the dates on all the photos. Is there a w

  • Help with an audio file - vows from a wedding.

    Evening all, My wife and I filmed a wedding yesterday and our wireless mic which was hooked up to the groom's lapel decided to cut out literally seconds before he spoke his vows. When I got the mic back from him, everything was soaked, literally drip

  • Can we call Plain JAVA Code online via MDM Cient

    Hi SDNers, For some validation purpose i need to write a JAVA Code(Some body told me that it can be possible i.e we can Java Code for doing Validation) i have two Questions. 1. Can we call JAVA Code online via MDM Client. 2. where i have to write thi

  • Hooking up an XBox 360/Wii to computer - is it possible?

    Is it possible? I have a pcmcia tuner for a windows laptop that I have - I hooked it up to that, but there is about 5 seconds of lag with it... Does anyone know of a solution to hook up a system to the Mac Pro/display? I wouldn't mind also having the

  • E3000 Access restrictions question

    Hi All, I have access restrictions set up for certain wireless devices in my home that the kids use to kick them off at 11 pm and keep them off all night. where I am running into a problem is I want to block these same devices from downloading anythi