Solved

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

Posted on 1998-11-18
6
215 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Impossible to extract MSI from new JAVA releases 2 50
compre toata in where clue oracle 4 57
stackato and cloud 4 74
servlet filter example 37 46
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…
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 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…
This video teaches viewers about errors in exception handling.

867 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

19 Experts available now in Live!

Get 1:1 Help Now