Solved

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

Posted on 1998-11-18
6
222 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
[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: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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

623 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