Solved

.gif  file can't be extracted from  .jar  file

Posted on 2002-03-17
6
247 Views
Last Modified: 2012-05-04
Created an applet that uses some .gif files, the first .gif the applet wants is
'neutral.gif'.  the applet runs fine standalone (from a PC subdirectory) in IE.  
When I JAR up the applet and load it to my server (CMSERVER1) and try to run
the applet from my server I get the following messages on the Java console.
(the  "Reached Flag01::init()"  message is a 'System.out.println()' message I put
in the applet to reassure myself that the applet itself was initializing).

Reached  Flag01::init()

com.ms.security.SecurityExceptionEx[Flag01.init]: cannot access file /\\CMSERVER1/LIGHTSPEED/neutral.gif
     at com/ms/security/permissions/FileIOPermission.check (FileIOPermission.java)
     at com/ms/security/PolicyEngine.deepCheck (PolicyEngine.java)
     at com/ms/security/PolicyEngine.checkPermission (PolicyEngine.java)
     at com/ms/security/StandardSecurityManager.chk (StandardSecurityManager.java)
     at com/ms/security/StandardSecurityManager.checkRead (StandardSecurityManager.java)
     at com/ms/security/StandardSecurityManager.checkRead (StandardSecurityManager.java)
     at com/ms/vm/loader/ResourceLoader.getImage (ResourceLoader.java)
     at com/ms/vm/loader/URLClassLoader.getImage (URLClassLoader.java)
     at com/ms/applet/AppletPanel.getImage (AppletPanel.java)
     at com/ms/applet/BrowserAppletFrame.getImage (BrowserAppletFrame.java)
     at java/applet/Applet.getImage (Applet.java)
     at java/applet/Applet.getImage (Applet.java)
     at Flag01.init (Flag01.java:64)
     at com/ms/applet/AppletPanel.securedCall0 (AppletPanel.java)
     at com/ms/applet/AppletPanel.securedCall (AppletPanel.java)
     at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
     at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
     at com/ms/applet/AppletPanel.run (AppletPanel.java)
     at java/lang/Thread.run (Thread.java)

It appears to me that the applet 'Flag01' is found, and it appears that
'neutral.gif' is found.  Why-come can't it access 'neutral.gif'????

'neutral.gif' is not open in something else (no other browser, not in an
editor, not in . . .)

'neutral.gif' has '''normal''' attributes; i.e., it is not 'read only' or
'hidden'

the client is  Win98, IE V5.50.4134.0600

the server is  IIS on WinNT V4.0, SP 5.

C:\Inetpub\wwwroot\LightSpeed (where my app is located) is shared, public,
FULL CONTROL.

I am running an Intranet (the server and my dev PC are the only two machines
on net - the cabling doesn't leave the room the two boxes are in).

have tried many different coding approaches in the .HTM - here is the latest:
  <applet
    align = LEFT
    code = "Flag01.class"
    codebase = "http://cmserver1/LightSpeed"
    archive = "http://cmserver1/LightSpeed/Flag01.jar"
    width = "30"
    height = "35"
  <PARAM NAME=flag VALUE="green">
  <PARAM NAME=interval VALUE="800">
  no browser support  
  </APPLET>

BTW - 'codebase' seems to have no affect one way or the other, I have
to code 'archive' or it doesn't find the .jar (leaving 'codebase' and
'archive' out completely - so that it looks in the .HTM containing subd as default
ain't working for me either!)

thanks - chris-m
0
Comment
Question by:christophm
6 Comments
 

Expert Comment

by:jk970
ID: 6874505
Can I see the piece of code handling the loading of images. Thx
0
 
LVL 2

Author Comment

by:christophm
ID: 6874723
Here is 'init()' - chris-m

    //--------------------------------------------------------------------------
    public void init() {
        String  sPanelNames[] =
            {"neutral.gif",     // neutral flag 0
             "rflag.gif",       // red flag     1
             "gflag.gif",       // green flag   2
             "bflag.gif",       // blue flag    3
             "yflag.gif",       // yellow flag  4
             "nflag.gif"};      // gray flag    5

System.out.println("\nReached  Flag01::init()\n");

        theInterval = getParameter("interval");
        theFlag     = getParameter("flag");

        iPauseInterval = Integer.parseInt(theInterval);
       
        if (theFlag.equals("neutral"))
            iFlag = 0;
        else    
        if (theFlag.equals("red"))
            iFlag = 1;
        else    
        if (theFlag.equals("green"))
            iFlag = 2;
        else    
        if (theFlag.equals("blue"))
            iFlag = 3;
        else    
        if (theFlag.equals("yellow"))
            iFlag = 4;
        else    
        if (theFlag.equals("gray"))
            iFlag = 5;
        else    
            iFlag = 0;

        for (int iIndex = 0;  iIndex < sPanelNames.length; iIndex++)
            imPanels[iIndex] = getImage(getDocumentBase(), sPanelNames[iIndex]);

        setBackground(new Color(192, 192,192));
    }
0
 

Expert Comment

by:maggari
ID: 6874842
Applet has its own security issues. So, when you access files from a system, you should have a security policy file on that system which explicitly gives permission to the applet.

use policytool to create a policy file. Refer to the following link on how to use policytool.


An example policy file you might wants looks like this:

grant codeBase "your_applets_codebase" {
permission java.io.FilePermission "yourfile", "read";
};

0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 9

Expert Comment

by:yongsing
ID: 6875777
It seems that you are trying to read the .gif file from the file system. If your .gif file is in the Flag01.jar file, you can call getClass().getResource() to read it:

for (int iIndex = 0;  iIndex < sPanelNames.length; iIndex++) {
  URL url = getClass().getResource(sPanelNames[iIndex]);
  imPanels[iIndex] = getImage(url);
}
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7901337
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ'd and pts removed
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7963029
Per recommendation, points NOT refunded and question closed.

Netminder
EE Admin
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse java  build path 6 59
Groovy problem when using SOAPUI : DispatchException occurred 7 46
servlet example 11 40
Selenium docs api java index 3 15
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question