Solved

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

Posted on 2002-03-17
6
227 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
Comment Utility
Can I see the piece of code handling the loading of images. Thx
0
 
LVL 2

Author Comment

by:christophm
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 9

Expert Comment

by:yongsing
Comment Utility
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
Comment Utility
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
Comment Utility
Per recommendation, points NOT refunded and question closed.

Netminder
EE Admin
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
strDist challenge 35 84
mapAB Challlenge 35 84
Core Java. What output will be and why ? 6 57
mockito example issue 8 26
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now