Solved

Displaying a image from local hard-disk(gif/jpg) through an applet using Netscape Communicator 4.5

Posted on 1998-11-18
6
220 Views
Last Modified: 2013-11-23
I want to display an image (gif/jpg) through a Java applet using Netscape Communicator 4.5 with out using any Web Server. The image and the Java application both has to be stored in my local hard-disk. I tried this using java.awt package but some netscape security exception is taking place.
0
Comment
Question by:inhuman
6 Comments
 

Expert Comment

by:robinM
ID: 1227657
If you're only using Netscape for testing purposes, try using appletviewer instead.  It comes with the JDK.

appletviewer <filename>.html
0
 

Accepted Solution

by:
horea earned 100 total points
ID: 1227658
Every applet uses a SecurityManager when it tries to execute some sensitive operation. Maybe this 4.5 Netscape has restrictions for reading files too. You could try to define your own SecurityManager and override methods that restrict file reading. That's works only for local loading of the applet because when the appllet is loaded from network the browser uses its local classes for SecurityManager.  
0
 

Author Comment

by:inhuman
ID: 1227659
I have already used Applet Viewer. It's working fine. But in Netscape Communicator 4.5 it is not working.

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 16

Expert Comment

by:heyhey_
ID: 1227660
please POST the applet code and the exception you receive ...


0
 

Author Comment

by:inhuman
ID: 1227661
Here I'm attaching the code...
----------------------------------------
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Applet1 extends Applet
{
    Image img1;
   
      public void init()
      {
            MediaTracker tracker = new MediaTracker(this);
            img1 = getImage(getDocumentBase(), "globe2.gif");
            tracker.addImage(img1, 0);
      }
      
      public void paint(Graphics g)
      {
          g.drawImage(img1, 2, 2, this);  
      }
}

And here I'm attaching the error message generated by Netscape Communicator 4.5...
--------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException
  at sun.awt.windows.WGraphics.drawImage(Compiled Code)
  at Applet1.paint(Compiled Code)
  at java.awt.Component.dispatchEventImpl(Compiled Code)
  at java.awt.Container.dispatchEventImpl(Compiled Code)
* at java.awt.Component.dispatchEvent(Compiled Code)
  at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
  at java.awt.EventDispatchThread.run(Compiled Code)
  at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
--------------------------------------------------
But it's working fine in Appletviewer...
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227662
the problem definitely is in this line
>> img1 = getImage(getDocumentBase(), "globe2.gif");
so
- you can try this
  img1 = getImage(getCodeBase(), "globe2.gif");
- you should try the TicTacToe applet from the JDK demo subdirectory ... it works (loads images) from the local disk on NN4.07
 i don't have NN 4.5 to test it

0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 102
Way to decrease size of apk file 9 110
Delete Android all or certain applications data programmatically 9 113
running on tomcat not jboss eap 7.0 3 33
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…
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

726 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