Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-11-18
6
Medium Priority
?
224 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 200 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

721 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