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
Solved

HOWTO make an Applet that show an Image in Netscape

Posted on 2001-06-18
7
168 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
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Accepted Solution

by:
tonus earned 50 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
more than one jdk and one jre 1 50
fibonacci ten numbers 4 45
servlet filter example 37 71
hibernate insert example 13 34
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

856 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