Applets and files

Hello!
I have built an applet which have to write, read, delete some files. I have write the permissions in the java policy file and I have no problem to run the applet with appletviewer. However, when I try to run it with the web browser the applet write the files but then it doesn't find them when the applet needs to read the files. I have been reading and I think I have to change my initial folder in the java console but I`m not sure about how I have to do it.
Thank you in antitipation for your help.

You can find the java policy file in your Java folder Java/JRE/1.4.1/lib/security/java.policy.
You have to open java.policy with the notepad and add the permissions you need and save the file. For example, if you want to allow your applet to read, write and delete files you have to add this lines to the java.policy file.
grant {
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
permission };
Anyway, google java applet permissions and you will find web pages where you can learn to use grant.

Similar Messages

  • Applets and File I/O

    As an attempt to familiarize myself with Java, I decided to create an applet to display my collection of collectible trading cards so that other collectors could view it and offer trades. The data is stored in a .txt file, which the applet reads when setting things up. The data is never edited by the applet, only read. Everything is working fine until I put the applet on the web page.
    At first, I ran into the security problem that it appears others have run into, and I searched the forums to figure out what to do about that. I'm not getting security exceptions any longer, I'm merely getting a "File Not Found" issue instead.
    The data file is included in the .jar file, so I didn't think I'd have to do anything other than this when I try to open the file stream:
    dataFile = new Scanner(new BufferedReader(new FileReader("MTDBData.txt")));;
    But this is what I see when I attempt to open the page:
    mDNSResponder: mDNS_SetPrimaryInterfaceInfo V4 address - incorrect type. Discarding.
    Exception: MTDBData.txt (No such file or directory)
    java.lang.NullPointerException
    at ListData.initializeListData(ListData.java:194)
    at MTDBManager.init(MTDBManager.java:129)
    at MTDBApplet.init(MTDBApplet.java:10)
    at sun.applet.AppletPanel.run(AppletPanel.java:378)
    at java.lang.Thread.run(Thread.java:613)
    I also tried putting the data file in the same directory with the .jar file on the web page, but that isn't working either. Does the first line indicate that I am doing something wrong when generating the security keys? Or do I need to preface the filename with pathing information in order for the applet to find it?
    Any assistance would be appreciated. Thanks!
    -- Josh

    After some investigation, I added a getCodeBase() before the file name to tell it explicity where to look. Now I'm seeing this:
    Exception: http:/(URL omitted)/mtdb_data.txt (No such file or directory)
    java.lang.NullPointerException
         at ListData.initializeListData(ListData.java:215)
         at MTDBManager.init(MTDBManager.java:136)
         at MTDBApplet.init(MTDBApplet.java:10)
         at sun.applet.AppletPanel.run(AppletPanel.java:378)
         at java.lang.Thread.run(Thread.java:613)
    I changed the file name from before and omitted the first part of the URL for privacy reasons. But what baffles me is that I can paste the full URL for the file it says it can't find into my browser, and the file pops up exactly as I would expect. I've tried this on two different web pages, and the only differece in the error is the first part of the URL, so I know the getCodeBase call is working properly. Has anyone seen this problem where it can't find the file despite the URL being correct? More importantly, does anyone know what to do about it?
    -- Josh

  • Security issues with applets and windows Vista when printing to file

    Hi, everyone
    I am currently developing an application that prints out the result of some calculations.
    from a Javascript file, the output finally ends up in a java applet that should print the file in a special printer.
    For debugging purposes I have created a File printer that creates a file from the output comming to the printer; this way I can debug what commands the printer is receiving.
    This worked well on Windows Xp; Vista always asks for permissions for the applet, and altough I guarantee these permissions, printer is not allowed to create the output file and reports an error writing
    after a little research, I have found that java applets have all permissions when certificated as trusted applications; all but file creating permissions
    anyone has any idea of how could I fix this problem?
    Thanks in advance

    HI,
    Have you actually signed your applet? If the signers certificate is the trusted key store for Java it should treat your applet as trusted. You can use a self signed certificate for testing as long as the cert is in the trusted key store.
    Some links that might help:
    [http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html]
    [http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/rsa_signing.html]
    Cheers,
    Shane

  • How to access a file via Applet and JavaScript

    I want to copy one file on the client machine from one place to another place from a Java Bean.
    To do this I created an applet and a Java Bean as follows:
    import java.applet.*;
    public class FileUtils extends Applet {
        public void copyFile(String src, String dest)  {
        private String source, destination; // setters/getters are there of course
        public void copyFile(ActionEvent actionEvent) { // Bean
            FacesContext fctx = FacesContext.getCurrentInstance();
            ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
            String command = "var s = '"+ source +"'; var d ='" + destination +"'; " +  " document.fileUtilsApplet.copyFile(s, d); ";
            erks.addScript(fctx, command);
        }Then I added the APPLET tag referencing the above class in the page fragment:
                    <f:verbatim>
                        <applet code="FileUtils.class" name="fileUtilsApplet" height="30"
                                archive="/context-root/Applet.jar"
                                width="200">
                        </applet>
                    </f:verbatim>From the Java console I can see the jar is successfully downloaded, but when the code in the bean is executed, the JavaScript code does not seem to do anything, as if the "copyFile" public method was not called at all and no output in the Java Console as well.
    Note that I already followed the guidelines at http://www.oracle.com/technetwork/developer-tools/adf/learnmore/71-adf-to-applet-communication-307672.pdf .
    Do you have any ideas?

    Ok, I can see the permission problem now:
    java.security.AccessControlException: access denied (java.io.FilePermission c:\myfile.txt 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.FileInputStream.<init>(Unknown Source)
    Edited by: user10047839 on 1-feb-2013 7.29
    signing the Jar and downloading the certificate permanently does not change anything in Firefox. The Java console keeps giving the above exception.
    Any idea?

  • Applets and classes in jar files

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

    I'd say the entire JAR will be downloaded.

  • Applets and accessing files confusion

    Hi
    I am confused about applets and their abilty to access files.
    I know that applets cannot access files on a users hard drive until given pemission but if i design an applet that needs access to files on the server where it is running will it be able to read and write those files in the same location as the applet without the need to set permissions?
    Any feedback would be great
    Neil

    The applet is very much able to read files from the server. This is easiest done by creating a URL and opening a stream to it:
    URL url = new URL(getCodeBase(), "file.dat");
    InputStream in = url.openStream();
    // read from the stream...
    in.close();
    Saving files to the server is also possible without setting permissions but it's a bit harder. In short, you need some sort of server that accepts a connection and saves what you send it to disk. The server can be eg. a servlet, a database or a FTP server.

  • Infobus applet and temporary files

    Hi,
    I have made an infobus applet and deploy it with the OAS407.
    Now I have seen, that each time I load the applet from the
    OAS407 the applet create 15 files in my temp-folder with the
    prefix jar_cache (for example: jar_cache40989.tmp).
    There is no problem with creating but there is a problem with
    deleting because there is no mechanism for automatic deleting.
    So I have to delete these files manually but I think that this
    is unuseable for end-user.
    Does anybody know how to bypass this problem ?
    Thanks.
    Nils
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Nils Buering ([email protected]):
    I ran into the same problem when I built an applet that uses DAC and runs the app module in the downloaded applet. The Java plugin 1.2.2 is creating these files in TEMP and these files are equal in size to the support jar and zip files downloaded to the browser. You can easily verify this by comparing file sizes (use the Properties facility when you right click a Windows file sname to see its exact size in bytes). The plugin does not delete these files when you exit the browser and thus re-creates them every time you restart the browser and access the applet from the web server potentially filling the user's disk.
    SUN has fixed this problem with the 1.3 plugin. Ater downloading and installing the 1.3 plugin, you must edit the applet's HTML file to add two new PARAM options: "cache_option" and "cache_archive". See http://java.sun.com/j2se/1.3/docs/guide/misc/appletcaching.html for instructions (a document titled "Applet caching in Java Plug-in") on doing this. This basically tells the plugin to use its own caching, instead of the browser's and doing this, the jar files created in the user's TEMP directory are deleted when you kill the browser.
    However, since Jdeveloper is not certified with Java 2 v1.3, I ran into problems with code that works under the 1.2.2 plugin. The applet no longer runs once its been downloaded: I get a permissions error in jbo.logging.show and jbo.logging.trace; to wit: (java.lang.ExceptionInInitializerError: java.security.AccessControlException: access denied (java.sql.SQLPermission setLog). So switching to the 1.3 plugin will fix the buildup of jar files in TEMP problem; but your applets may no longer work! Best to wait until Jdeveloper is certified with 1.3 then you can run the 1.3 plugin successfully.
    Hi,
    I have made an infobus applet and deploy it with the OAS407.
    Now I have seen, that each time I load the applet from the
    OAS407 the applet create 15 files in my temp-folder with the
    prefix jar_cache (for example: jar_cache40989.tmp).
    There is no problem with creating but there is a problem with
    deleting because there is no mechanism for automatic deleting.
    So I have to delete these files manually but I think that this
    is unuseable for end-user.
    Does anybody know how to bypass this problem ?
    Thanks.
    Nils<HR></BLOCKQUOTE>
    null

  • Calling JSP file from applet and passing a parameter in POST form

    Hi,
    Can anybody help me. I want to call a JSP page from within a applet and to this JSP page i want to pass the query which the applet has created in POST method.
    I want to refresh the applet page with the new JSP page by passing the query object so the jsp page with take this query, and display the resultset
    Thanks in advance
    JK

    Review
    URL.openConnection()
    and HttpURLConnection

  • IIS, Javascript, Signed Applet and ASP Blank Page Problem

    Hi,
    I'm having a problem using a Signed Applet in a site that runs in a IIS (Windows Server 2003).
    My aspx web page uses the applet to read my smart card and get information from it.
    This applet uses an auxiliar dll (stored in a second Signed Jar file) in order to read the information from my smart card.
    The way the solution is design:
    1) Aspx page is asked from server
    2) Internet Explorer recieve the page and asks the server for it content (images, applet, javascripts, etc)
    3) After this the JVM runs (console opens)
    4) After the Aspx page render fully a javascript register onload fires and call an applet method
    5) Applet receive the call and run the logic of the method:
         - reads the smart card;
         - calls Javascript function in order to fill aspx fields with information from smart card
         - calls Javascript function the simulates a click in a botton of aspx page (in order to call server side part sending data readed from smart card to server)
    5) The server makes some logic with the information receive and responds to client registering in aspx page a call to another Javascrit function
    6) The client received the asnwer from server and runs the Javascript function registered on step 5)
         This Javascript calls another method from applet and runs the following logic:
         - reads more information from smart card;
         - call javascript function in order to fill more fields of aspx page with the information readed
         - calls Javascript function the simulates a click in a botton of aspx page (in order to call server side part sending data readed from smart card to server)
    7) The server makes some logic and call another pages with no Applets
    8) Client asks for a second page with the same applet and we start with another logic express on steps 1);2);3),4);5) and then 7).
    This is all ok, until sometimes the server stop responding correcly for requests regarding this two pages with the Applet.
    When this happens the server just responds with a blank page.
         - with fiddler I can seer the request for the aspx page (that uses the applet)
         - but server responds with a blank html page
    The JVM doesn't fire.
    The IIS log don't show errors.
    The eventviewer doesn't show errors.
    The problem is solved with an IIS reset or a Application Pool reset.
    After a while the problem returns.
    This problem occours for other user in another machine, the server just stops responding correcly to request regarding pages with applets, the other pages still continue to work.
    If we disable Java Control Panel->Advanced->Java Plug-in->Enable the next-generation Java Plug-in the problem seend to stop, but we can't force all clients to disable this option right?
    Or there is a way to force the Applet to run with this option disabled?
    As anyone experience similar problem?
    Regards,
    OF

    This is all ok, until sometimes the server stop responding correcly for requests regarding this two pages with the Applet.
    When this happens the server just responds with a blank page.
    - with fiddler I can seer the request for the aspx page (that uses the applet)
    - but server responds with a blank html pageWell, if http requests look identical in case of success and failure (pay attention to cookies, etc) then it has to be something on the server side.
    It could be that server gets into this wrong state because of previous requests made by applet but it is hard to tell.
    I am not clear how old/new plugin can make a difference unless your applets run in the legacy mode (i.e. you are actually trying to reuse SAME instance of the applet when
    it is loaded next time).
    I'd start with
    1) carefully comparing good/bad sessions
    2) checking whether server will serve correct response to another client when it serves "bad" page for current client
    3) add debug statements to aspx - it is scripted page, may be some condition is not met and then it returns blank?
    4) record all http requests in one session until you get to "error" state and then use any http server testing tool to "replay" this set of requests.
    You should be able to get server into the same state without use of applet. Then you can try to tweak set of requests to see what makes a difference.

  • How do I integrate Java Applet and JavaScript?

    Hi:
    This has been asked before, I have read the archives, yet I'm still left with some doubts, and some posts are VERY old and may not apply today. (sorry, some questions might seem stupid, this is my first applet). The purpose is to create a light weight application for managing certificates stored on a smart card, requesting certificate renewal from a server and installing the issued certificate on the card.
    I need to create an applet (signed) to bridge the gab caused by the security limitations of JavaScript in order to access the smart card on the client. The applet will manage certificates on the card and do client-card interaction, while all client-server and user interaction is done by AJAX/JavaScript.
    So, the applet is actually supposed to be an invisible object embedded on the page that is accessed by the JavaScript. How do I go about this?
    - is there any reason to prefer JApplet over Applet?
    - do the JavaScript need to invoke start() or init() or is this done on page load?
    - are there limitations on data exchange with the applet (ie. only string types)?
    - how do I throw exceptions from the applet to the calling script?
    and: will is it better to let JavaScript do all http to keep the applet light, or to let the applet fetch files given a URL (to fetch the new certificate)?
    If the applet is stored in a jar-file, how do I indicate which class/method to invoke? Do the JavaScript have access to public methods only?
    Thanks for your advice and suggestions,
    Erik

    Hi,
    Are you still interested?
    I can work with you over this.
    Adil

  • I'm crazy!Applet and JNA Error:Library 'jnidispatch' was not found!

    Hi all,
    sorry to bother you, I really have no idea how to do JNA and Applet. I'm hardly mazy, man.
    Every time it will throw an error to me :
    Exception in thread "thread applet-JNAApplet-1" java.lang.UnsatisfiedLinkError: Library 'jnidispatch' was not found by class loader sun.plugin2.applet.JNLP2ClassLoader@291aff
         at com.sun.jna.Native.getWebStartLibraryPath(Native.java:858)
         at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:576)
         at com.sun.jna.Library$Handler.<init>(Library.java:140)
         at com.sun.jna.Native.loadLibrary(Native.java:372)
         at com.sun.jna.Native.loadLibrary(Native.java:357)
         at JNAApplet.init(JNAApplet.java:15)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)My program is so easy, I just want use Applet to revoke JNA and use the JNA to load a native lib.
    here is the structure of my program:
    Applet code :
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import com.sun.jna.Native;
    public class JNAApplet extends JApplet {
         public static Kernel32 kernel32 = null;
         @Override
         public void init() {
              createGUI();
              kernel32 = (Kernel32)Native.loadLibrary("Kernel32", Kernel32.class);
              if (kernel32 == null) {
                   System.out.println("load kernel32 fail!");
              } else {
                   System.out.println("load kernel32 success!");
         private void createGUI() {
              JPanel panelCenter = new JPanel();
              JButton butTest = new JButton("Test");
              panelCenter.add(butTest);
              setContentPane(panelCenter);
    }When I run it on debug mode, it is ok! but when I deploy it , it will throw above error message to me.
    My Applet html:
    <html>
         <head>
              <title>JNA Applet</title>
         </head>
         <body>
         <script src="deployJava.js"></script>
        <script>
            var attributes = { code:'JNAApplet',  width:300, height:300} ;
            var parameters = {jnlp_href: 'JNAApplet.jnlp'} ;
            deployJava.runApplet(attributes, parameters, '1.5');
        </script>
         </body>
    </html>File 'JNAApplet.jnlp':
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="" href="">
        <information>
            <title>JNA Applet</title>
            <vendor>Steven</vendor>
        </information>
        <resources>
            <j2se version="1.5+"
                  href="http://java.sun.com/products/autodl/j2se" />
            <jar href="JNAApplet.jar" main="true" />
        </resources>
        <applet-desc
             name="JNA Applet"
             main-class="JNAApplet"
             width="300"
             height="300">
         </applet-desc>
         <update check="background"/>
    </jnlp>     I really have no idea. and I can't search any usefull infomation from Google and officer site.
    Can any one help me? Thank you very much!!!!

    Hi AndrewThompson64:
    Did you mean the JNA project? Or are you refering to JNI, or ..something else?Yes, I mean is that I wanna jna.jar to replace JNI to code with Applet. I want Applet can run native library(.dll files).
    That reads like so much nonsense to me.Sorry fo that.
    Was there any 'caused by' part that you trimmed? I expected to see something to do with 'Security' or 'AccessControl'.Sorry, I can't saw any 'cause by' subsentence there. This message is just gain from Applet Console.(Is there any method to gain more message?)
    About 'Security' and 'AccessControl' I just modify my java.policy file to allpermission. Subsequently, I signed all jar files.
    For now I have 3 jar files(all have been signed ):
    --example.jar :  for this little program.(code include applet and application entry)
    --jna.jar
    --win32-x86.jar : include kernel32.dll and jnidispatch.dll for win32 and x86.
    and 2 JNLP files:
    --JNAApplet.jnlp the entry is JNAApplet.class (this jnlp does not work)
    --JNAApp.jnlp     the entry is JNAApp.class  (this jnlp works)
    And for now new error message show like this:
    Exception in thread "thread applet-JNAApplet-1" java.lang.UnsatisfiedLinkError: Library 'Kernel32' was not found by class loader sun.plugin2.applet.JNLP2ClassLoader@4aeb52
         at com.sun.jna.Native.getWebStartLibraryPath(Native.java:858)
         at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:97)
         at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:228)
         at com.sun.jna.Library$Handler.<init>(Library.java:140)
         at com.sun.jna.Native.loadLibrary(Native.java:372)
         at com.sun.jna.Native.loadLibrary(Native.java:357)
         at JNAApplet.init(JNAApplet.java:12)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Did you mean invoke?
    Revoke: To annul by withdrawing.
    Invoke: To call on.Yes, you got it. Thank you.
    The JNLP file is invalid. ..I was about to put my 'standard' text here, but I'm sick of saying it. Search the forum for my posts - 50% of them, at least, mention validation and how to go about it.
    Also, the applet-desc requires a documentbase.Thank you, I really think I have some invalid section. But I can't find it, and you said 'Search the forum for my posts - 50% of them...' , I can read the JNLP structure on site of sun and I can to read you post too(I'm doing like this).*I only want to know about how to load "native lib like *.dll" properly*.
    What 'officer site'?I mean jna project site. Sorry for ambiguity.
    Please fix that sticky '!' key. One '!' indicates astonishment, while two or more typically indicates a bozo. Thanks for your advice. Because I tried to find solution do my best lasting two days. I got nothing. I'm sadness.
    here post my new files:
    import javax.swing.JFrame;
    import com.sun.jna.Native;
    public class JNAApp {
         public static Kernel32 kernel32 = null;
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              kernel32 = (Kernel32)Native.loadLibrary("Kernel32", Kernel32.class);
              JFrame frame = new JFrame();
              frame.setSize(500, 500);
              frame.setVisible(true);
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import com.sun.jna.Native;
    public class JNAApplet extends JApplet {
         public static Kernel32 kernel32 = null;
         public void init() {
              createGUI();
                   kernel32 = (Kernel32)Native.loadLibrary("Kernel32", Kernel32.class);
         private void createGUI() {
              JPanel panelCenter = new JPanel();
              JButton butTest = new JButton("Test");
              panelCenter.add(butTest);
              setContentPane(panelCenter);
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="" href="">
        <information>
            <title>JNA Applet</title>
            <vendor>Steven</vendor>
        </information>
        <resources>
            <j2se version="1.5+"
                  href="http://java.sun.com/products/autodl/j2se" />
             <jar href="JNAApplet.jar" main="true"/>
             <jar href="jna.jar"/>
        </resources>
           <resources os="Windows" arch="x86">
             <nativelib href="win32-x86.jar"/>
             <nativelib href="kernel32.jar"/>
           </resources>
        <applet-desc
             documentBase=""
                name = "success"
             main-class="JNAApplet" width = "200" height = "200">
         </applet-desc>
         <update check="background"/>
           <security>
             <all-permissions/>
           </security>
    </jnlp>     
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="" href="">
        <information>
            <title>JNA Applet</title>
            <vendor>Steven</vendor>
        </information>
        <resources>
            <j2se version="1.5+"
                  href="http://java.sun.com/products/autodl/j2se" />
             <jar href="JNAApplet.jar" main="true"/>
             <jar href="jna.jar"/>
        </resources>
           <resources os="Windows" arch="x86">
             <nativelib href="win32-x86.jar"/>
             <nativelib href="kernel32.jar"/>
           </resources>
        <application-desc
             main-class="JNAApp">
         </application-desc>
         <update check="background"/>
           <security>
             <all-permissions/>
           </security>
    </jnlp>     Thanks & Best Regards,
    Su Heng

  • HELP! How to get an applet and place it into an application?

    Hi,
    We have a third party java applet that runs on a specific server. We don't have the code for this applet, only the .class file. We usually connect to the server using any browser with HTTP protocole like http://ourServer. Then we are asked for our username and password and then the applet loads and we can run it. The applet is design to remotely control a piece of equipment. The applet runs on the server and directly coomunicate with this piece of equipment and gives us bak some information into a graphic interface.
    What we want to do is to integrate the applet into one of our stand alone application to eliminte the need for a browser. Since Applet can be add directly into any Panel I've tried something like :
    public myApp() {
         Container c = getContentPane();
         ThirdPartyApplet myApplet = new ThirdPartyApplet();
         c.setLayout(new BorderLayout());     
         c.add(myApplet,BorderLayout.CENTER);
         myApplet.init();
    Of course I've a local copy of the .class file and I've included it into my ClassPath. I can get the interface this way but I can't run it, nothing seems to work.
    I'm not an expert in applet, I don't know how this one works, but it seems that we need to get the one on the server and run it, just as a browser would do. We've also tried to integrate a Browser into our app. We've tried NetClue and IceBrowser but only IceBrowser seems to work perfectly with our applet and we don't have the money for an IceBrowser license.
    So what is wrong with the integration of an applet into a stand alon application?? How do I simulate a Browser and get the applet from the server?
    Can anyone help me on this one?
    Thanks
    Steeves

    There's a link to download the Java source on this page.
    http://java.sun.com/j2se/downloads.html
    Once you have it, look for the appletviewer source in
    src\share\classes\sun\applet

  • How to load an applet jar file?

    Hello everyone,
    I have an applet that uses my own jar file and approximately 6 third party jar files. I set up jar indexing (jar -i) which will download the jar files when they are needed. All seems to work well, but now I want to manually load the jar files which I cannot get working.
    When the applet starts, about 1/2 of the jar files are downloaded (because they are needed at startup). I then want to load the additional jar files in the background, after the gui is initialized. I have tried this using the below thread which is executed from within the applet's start method:
    // Try to load additional jar files in background by loading a class from each jar file.
    Thread loadClass = new Thread() {
      public void run() {
        System.out.println("Loading classes...");
        try {
          // Tried loading classes this way, doesn't work.
          getClass().getClassLoader().loadClass("pkg1.Class1");
          getClass().getClassLoader().loadClass("pkg2.Class2");
          getClass().getClassLoader().loadClass("pkg3.Class4");
          getClass().getClassLoader().loadClass("pkg4.Class4");
          /* Loading classes this way doesn't work either.
          Class.forName("pkg1.Class1");
          Class.forName("pkg2.Class2");
          Class.forName("pkg3.Class3");
          Class.forName("pkg4.Class4");
        catch(ClassNotFoundException e) {
          // First attempt to load a class (pkg1.Class1) throws exception.
          System.out.println("Can't find class: " + e.getMessage());
    loadClass.start();As you can see from above I am trying to load a class from each of the jar files so that the jar files would load into memory/cache. Unfortunately, it cannot find the classes. These are the errors from the java console:
    Loading classes...
    Loading: pkg1.Class1
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with no proxy
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with cookie "JSESSIONID=some_big_long_char_list"
    Can't find class: pkg1.Class1
    So it appears the jar file is not being downloaded. When I take away the dynamic jar loading (removing the "jar -i" & adding them all to the applet archive list) the thread executes correctly. So I know the class names, etc, are correct. How does one load an applet jar file?
    Any help/suggestions are appreciated.

    The above error I posted was because I forgot to index the jar files. That is why it couldn't find the jar file. I thought I was getting farther along with my problem, but I apparently just forgot to index the jars. I am now getting the problem that I got yesterday...
    The applet freezes/hangs when it hits the thread. The GUI never opens (even though I'm running this thread right after the gui shows). The java console quits responding and the applet just stays the grey screen. I also tried the invoke later that you suggested.
    public void start() {
      // ...initialize gui...
      // Applet freezes and remains grey, also the java console freezes.
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          System.out.println("Loading classes...");
          try {
            // When I comment out the below forName calls, the thread will still run evidenced through the done print statement.
            Class.forName("pkg1.Class1");
         Class.forName("pkg2.Class2");
         Class.forName("pkg3.Class3");
         Class.forName("pkg4.Class4");
            System.out.println("...Done loading classes");
          catch(Exception e)     {
            System.out.println("Can't find class: " + e.getMessage());
    }

  • Question about Java Applet Jar file signing.

    These questions pertain to Java 6 Standard Edition 1.6.0_22-b04 and later.
    I have gone through the Oracle Java Tutorial for generate public and private key information
    to sign a jar file, and how to sign the jar itself, all at
    [http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html]
    , and seek some clarification on the following related questions:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?
    -using the policytool policy file generator, what do I need to add under "Principals"
    (if anything) when dealing with a Java applet? Are Codebase and SignedBy simply author information?
    -If I choose to use a java.security.Permission subclass object set up in equivalent fashion within the Applet,
    which class within the Applet jar do I instantiate that object in? Does it need to be mentioned
    in the applet's jar Manifest.MF file?
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?
    -With this being the case, can the applet now escape
    the sandbox, be it with or without the stipulated
    policy permissions?

    848439 wrote:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?Just sign the applet, the policy file is not necessary.
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?No.
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).No. For a signed Jar, all the information is contained inside the Jar.
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?No. It is the JVM that determines when to pop the confirmation dialog.
    -With this being the case, can the applet now escape
    the sandbox, ..Assuming the end-user OK's the trust prompt, yes.
    ..be it with or without the stipulated
    policy permissions?Huh?

  • [SOLVED]Network Manager Applet and nmcli failing after GCC upgrade

    Hi All,
    So I went to update my system today and there were only like 8 or 9 updates. Like many other people I had an issue with gcc and pacman. To fix this I ran
    pacman -S gcc
    Then I ran:
    pacman -Su
    which updated pacman itself. On reboot though I noticed network manager applet was unable to find any of my network devices despite the fact that network manager was running and I had an IP address. I killed nm-applet and re-ran it and it spewed errors about not being able to connect to network manager. I tried running nmcli and it did the same thing. However, when I run nmcli as root it works. Looking at the arch wiki they suggest you be a part of the wheel and network group which I made sure I was. Everything was working up until I ran those two updates though. Anyone else have this happen or have any idea what is wrong?
    Thanks,
    Hemmar
    EDIT: Never mind - a patch was released for consolekit which fixes the problem.
    Last edited by hemmar (2012-04-13 00:36:49)

    Hi guz46
    I have already tried removing the ! and the same thing happened ... but I realised today that I was being automatically connected to "Auto eth0" despite there being no cable present. When automatic connection was disabled on "Auto eth0" my 3G connection (ppp0) connected fine.
    Could you clarify that the preferred set-up in the /etc/rc.conf for the interfaces is without the !. The Wiki for networkmanager says to disable them, but then states that some may need to be reenabled with no explanation. The purpose of this confuses me!
    Thanks for you help anyways,
    Scott
    EDIT:
    I appear to have fixed my problem with the auto connection on the various interfaces by updating my /etc/rc.conf file to:
    #Static IP example
    #eth0="dhcp"
    ppp0="dhcp"
    wlan0="dhcp"
    eth0="dhcp"
    INTERFACES=(ppp0 wlan0 eth0)
    Thus ensuring that I can connect in order of preference.
    Last edited by ScottArch (2009-11-03 18:48:47)

Maybe you are looking for

  • Lv 6.1 crashing

    Hi everyone, I'm experiencing a rather annoying (and increasingly frequent) problem.... I have a program using several different modules for instrument communication (Spectrometer, filter wheel, monochromator etc) which has been running fine for a ye

  • How can i get new apple id with out using credit card or visa card

    how can i get a new apple id with out using credit card or visa card?

  • Oracle 9i contines to ask for a password

    So that we may better diagnose DOWNLOAD problems, please provide the following information. - Server name - Filename - Date/Time - Browser + Version - O/S + Version - Error Msg I have downloaded oracle 9i personal and have manged to install it, howev

  • No appropriate line item is contained in this document : Error in F-03

    HI All, when I am trying to clear a G/L account in F-03, for a document I am getting the error 'No appropriate line item is contained in this document' I can see the open item in FBL3N and this is not a special G/L item what can be the possible reaso

  • Iphoto won't open the pix from iphone camera role

    i've rebooted the phone and all that shows in iphoto when it's mounted the iphone is the white dotted thumbnail frames, but no pix and when trying to still import, says cannot import the numbe rof pix there...not sure how to fix this..this happened o