Solved

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

Posted on 2002-03-17
6
252 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fibonacci ten numbers 4 45
JavaFX TableView not displaying correctly 3 51
mysql jsp example issue 32 48
sql import cannot be resolved jsp 3 44
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

790 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