Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-03-17
6
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

661 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