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

x
?
Solved

HOWTO make an Applet that show an Image in Netscape

Posted on 2001-06-18
7
Medium Priority
?
173 Views
Last Modified: 2013-11-23
Hello!
My source:
import java.applet.*;
import java.awt.*;
public class A extends Applet {
     Image img;
     public void init() {
          img = getImage(getCodeBase(), "img.gif");
     }    
     public void paint(Graphics g) {
          g.drawImage(img, 0, 0, this);
     }
}
I compile: javac A.java to produce A.class, then I type:
jar -cvf A.jar A.class img.gif
to produce A.jar
After I make this html file:
<html><body>
Keypad<applet code="A.class" archive="A.jar" width="200" height="300">
</applet></body></html>

public on PWS an run Netscape on htis page.
It doesn't work. Why?
If I don't use jar and take off archive"A.jar" It works well.
I can't undertand.
OBS: With IE it works well to.
My Netscape vertions: 4.03, ..., 4.73

thanks a lot!
0
Comment
Question by:jussara
[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
7 Comments
 
LVL 2

Expert Comment

by:iDeb
ID: 6204255
you might want to specify the full path to the archive, or include the codebase attribute
0
 
LVL 2

Expert Comment

by:iDeb
ID: 6204265
I also suggest use the OBJECT tag instead of APPLET, since the latter has been deprecated in favor of the former.... http://www.webspawner.com/cc/html/object.html
0
 
LVL 2

Expert Comment

by:iDeb
ID: 6204266
I also suggest use the OBJECT tag instead of APPLET, since the latter has been deprecated in favor of the former.... http://www.webspawner.com/cc/html/object.html
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 1

Accepted Solution

by:
tonus earned 200 total points
ID: 6206490
To Load an image from a jar file, you got use
 getResource() or getResourceAsStream()

Added below a sample code which returns an image from the jar file

 public Image getImageFromJAR(String s) {
    InputStream inputstream = getClass().getResourceAsStream(s);
    if(inputstream == null) {
      return null;
    }
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    byte abyte0[] = new byte[1024];
    try {
      int i;
      do {
        i = inputstream.read(abyte0);
        if(i != -1)
        bytearrayoutputstream.write(abyte0, 0, i);
      } while(i != -1);
      inputstream.close();
    }catch(IOException _ex) {
      try {
        inputstream.close();
      } catch(IOException _ex2) { }
      return null;
    }
    return Toolkit.getDefaultToolkit().createImage(bytearrayoutputstream.toByteArray());
  }
0
 

Author Comment

by:jussara
ID: 6328755
From wich version of netscape the tonus sample works?
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9010003
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to tonus]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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