Solved

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

Posted on 2002-03-17
6
275 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:
Suggested Courses

617 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