Solved

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

Posted on 1998-11-18
6
212 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Receive file in Servlet 1 36
java set up 1 48
firstChar challenge 13 86
solarwind tftp server 2 32
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

762 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

20 Experts available now in Live!

Get 1:1 Help Now