Inner classes should appear in jar?

At first thanks for answering my question: I did resolve the problem of excluding files, so the .java and .html are not present anymore�.. but the problem stays: I do see the applet in the applet viewer but not on the safari (mac Version 3.0.4) browser. The tag, I think is ok:
<applet code="Slides.class" width="500" height="500" archive="slides.jar"></applet>
A second question related to this problem might be, that the two inner class files that show up in the build/class file are not present in the jar. The application consists of just one single class (I already moved some initialization stuff from the constructor to the init). The class is called Slides.class and the compiler generates the Slides$1, Slides$xxx and Slides$yyyy. Should they all be included in the jar I only so the main class.
Thanks a lot
willemjav
The (still dirty) code is here (you need a folder with images files called xxxx#img01 etc.) and a first image called firstpic.jpg
* Slides
* Created on February 3, 2008, 10:25 PM
* The application does an applet slide show
* of a list of images files set in the folder
* Imagestore each 7 seconds changes the picture
* see DURATION
* still to do an image list check on file extentions
* and a fade in/ out
* @author wdragstra
import java.awt.*;
import java.awt.Image;
import java.awt.event.*;
import java.text.DecimalFormat;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.net.URL;
import java.io.*;
import java.awt.image.BufferedImage;
public class Slides2 extends JPanel implements ActionListener {
private int count, maxcount, x, y, duration,
textposx, textposy, imgwidth, imgheight;
static int framew, frameh;
private boolean intro;
private static final int LOAD = 7000, PAUSE=4000; // animation duration
private static final String FILE_NAME="Imagestore"; // the image file name in work directory
private File directory; // File object referring to the directory.
private String[] picfilenames; // Array of file names in the directory.
private JOptionPane infoPane;
private JPanel picttextPanel;
private JLabel textLabel;
private Timer load, timer, pause;
private Image firstpic;
private BufferedImage OSC;
public Slides2() { // construtor
framew = 350; // frame size to be set
frameh = 390;
textposx = 130; // text position to be set
textposy = 20;
duration = 9000; // image duration to be set
count=0; // image and textstring counters
maxcount = 0;
load = new Timer(LOAD, this); // the three animation timers
readImageFilelist(FILE_NAME); // get the content of the image folder
firstpic = downloadImage("firstpic.jpg");
orderImages();
timer = new Timer(duration, this);
infoPane = new JOptionPane(); // containing the 1) firstpic.jpg the
picttextPanel = new JPanel(); // first picture or only picture
textLabel = new JLabel(" INFO ", JLabel.CENTER); // 2) the parameter file called
this.setLayout(null); // imageanimater.txt 3) the imgefiles
textLabel.setBounds(textposy,textposx, 300 , 50); // with name xxxxx#img01 - 99
add(textLabel);
intro = true;
load.start();
public void actionPerformed(ActionEvent evt) { // timer listner
if (evt.getSource() == load) { // first timer only ones for first picture
// second timer for image duration
load.stop();
timer.start();
intro=false;
repaint();
if (evt.getSource() == timer) {
if (count == maxcount)
count = 0;
repaint();
count++;
void readImageFilelist(String dirname) { // gets the list of images
directory = new File(dirname); // of folder imagestore
if (directory.isDirectory() == false) { // in work directory
if (directory.exists() == false)
JOptionPane.showMessageDialog(infoPane,
" there is no directory called " + directory);
else
JOptionPane.showMessageDialog(infoPane, directory +
" is not a directory. ");
else {
picfilenames = directory.list(); // stores the list of file names
for (int i = 0; i < picfilenames.length; i++) {
if (imageNamecheck(picfilenames)) { // check correct file extension #img
picfilenamesmaxcount = picfilenames; // eliminate the incorrect ones
maxcount++;
if (maxcount == 0)
JOptionPane.showMessageDialog(infoPane,
"no valid files present ");
private boolean imageNamecheck(String st) {
int pos = st.indexOf("#img");
if (pos == -1)
return false;
else return true;
private int imagePos(String st) {
int posnmb=0; // convert string-number into int
int pos = st.indexOf("#img"); // when no image present returns -1
if (pos==-1) {
JOptionPane.showMessageDialog(infoPane,
"The file has�t the correct format #img01-#img99 ");
return 0;
else
return pos+4;
private void orderImages() { // sort de file list of images 00-99
int lastarray = maxcount-1;
int trynmb=0, maxnmb=0, index=0, pos=0;
String tempfl="";
while(lastarray != 0) {
index = 0;
pos = imagePos(picfilenames[0]);
try { maxnmb = Integer.parseInt(picfilenames[0].substring(pos, pos+2));
catch ( NumberFormatException e ) {
JOptionPane.showMessageDialog(infoPane,
"File format: #img01-#img99 " + e);
for (int i = 1; i <= lastarray; i++) {
pos = imagePos(picfilenames);
try { trynmb = Integer.parseInt(picfilenames.substring(pos, pos+2));
catch ( NumberFormatException e ) {
JOptionPane.showMessageDialog(infoPane,
"File format: #img01-#img99 " + e);
if (trynmb>maxnmb) {
maxnmb = trynmb;
index=i;
tempfl = picfilenameslastarray;
picfilenameslastarray = picfilenamesindex;
picfilenamesindex = tempfl;
lastarray--;
// for (int i = 0; i < maxcount; i++) {
//JOptionPane.showMessageDialog(infoPane,
// "last array " + i + " filename " + picfilenames);
private Image scaleImage(BufferedImage bimg) { // scale buffered image into image fill
try {
imgwidth = bimg.getWidth(this);
catch (Exception e) {
JOptionPane.showMessageDialog(infoPane, "can not get image width " + e);
try {
imgheight = bimg.getHeight(this);
catch (Exception e) {
JOptionPane.showMessageDialog(infoPane, "can not get image height " + e);
double scalerate = calcScale(imgwidth, imgheight); // calls the actual scaling method
imgwidth = (int)(imgwidth * scalerate);
imgheight = (int)(imgheight * scalerate);
x = (int)(framew - imgwidth)/2;
y = (int)(frameh - imgheight)/2;
DecimalFormat myFormatter = new DecimalFormat("######.##");
String xx = myFormatter.format(scalerate);
String yy = myFormatter.format(scalerate);
//JOptionPane.showMessageDialog(infoPane,
// "image size " + imgwidth + " / " + imgheight + " new size " + newidth + " / " + newheight + " scalerate " + xx
// + " insets " + insetw + " / " + inseth );
try {
Image img = bimg.getScaledInstance(imgwidth, imgheight, bimg.SCALE_FAST); // the actual scaling
return img;
catch (IllegalArgumentException e) {
JOptionPane.showMessageDialog(infoPane, " can not scale the image " + bimg + " " + e);
return null;
private double calcScale(int imgwidth, int imgheight) {
double sc=0, x=0;
if ((double)framew-imgwidth < frameh-imgheight) { // gets the smallest side of the picture
sc = (double)framew/imgwidth; // to scale to frame size (sc)
else {
sc = (double)frameh/imgheight;
return sc;
private Image downloadImage(String filename) { //downloads image and call the scaling
BufferedImage bufimg=null;
Image img=null;
ClassLoader cl = Slides2.class.getClassLoader();
URL imageURL = cl.getResource(filename);
try {
bufimg = ImageIO.read(imageURL);
img=scaleImage(bufimg);
catch (Exception e){
JOptionPane.showMessageDialog(infoPane, " can not download " + filename + " " + e);
return img;
private void displayText(int cnt) {
textLabel.setFont(new Font("Serif", Font.BOLD, 18));
textLabel.setForeground(Color.RED);
textLabel.setText("xcount maxcount " + count + " / " + maxcount);
public void paintComponent(Graphics g) { // the timer calls the component
// to draw the pictures
if (intro) { // the first pic and its display time
g.drawImage(firstpic,0, 0, imgwidth, imgheight, this);
else {
//g.drawImage(img, dest_x1, dest_y1, dest_x2, dest_y2,
// source_x1, source_y1, source_x2, source_y2, imageObserver); x=width y=height
g.setColor(Color.WHITE);
g.fillRect(0, 0, framew+10, frameh+10);
g.drawImage(downloadImage(picfilenamescount),x, y, imgwidth, imgheight,this);
//g.drawImage(firstpic,0, 0, imgwidth, imgheight, this);
displayText(7);
}

If the application is expecting to find an inner class in the jar - then yes, it must be there.
Put it in there and see what happens - it is probably needed there.

Similar Messages

  • Private inner classes, should this compile:

    class Outer
    &nbsp&nbsp&nbsp&nbspclass InnerA;
    &nbsp&nbsp&nbsp&nbspclass InnerB;
    &nbsp&nbsp&nbsp&nbspclass InnerA
    &nbsp&nbsp&nbsp&nbsp{
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspInnerB* m_inner;
    &nbsp&nbsp&nbsp&nbsp};
    &nbsp&nbsp&nbsp&nbspclass InnerB
    &nbsp&nbsp&nbsp&nbsp{
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspInnerA* m_inner;
    &nbsp&nbsp&nbsp&nbsp};
    The Sun Studio 8 C++ compiler says that InnerB is not accessible from InnerA and vica-versa.
    However, both classes are members of the outer class and I would think that just like member functions, they should have access to all the declarations (prviate or not) in the outer class.
    Is the compiler correct to complain about this?
    Kind Regards,
    Dave.

    the current wording of the standard favours the Sun' s interpretation.
    gcc have gone with assuming that core language defect report 45 will be accepted which would allow this.
    see http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#45 .
    /lib

  • Nested and inner classes

    What's the difference between them? As far as i can tell, a nested class is usually public and a inner class is almost always private. Can some one please provide an example?
    Thanks a lot guys.

    inner classes == nested classes - static classes
    In other words, inner class should belongs to the instance of the enclosing class.

  • Compiling inner classes

    Hi,
    I have an applet with inner classes (the applet is contained in a single .java file). When I compile the applet, a number of *$*.class files are created for the inner classes. However, a friend of mine compiles the same .java file and he gets a single .class file. He can't see any files corresponding to the inner classes. My compiler is version 1.4.0, his is 1.4.2. Can you suggest how my friend can generate the *$*.class files corresponding to the inner classes?
    Thanks for your help.
    Miguel
    PS If the .jar file does not contain the *$*.class files, then appletviewer can't find the inner classes.

    Let me try again. My friend gets a single .class file.
    If he invokes the applet like this:
    <APPLet CODE="myapplet.class" WIDTH=100 HEIGHT=100>
    he has no problems at all.Because all the necessary files are there. Including the inner class files. Why he doesn't see them is another problem.
    However, if he puts his class file in myjar.jar and
    invokes the applet like this:
    <APPLet CODE="myapplet.class"
    ARCHIVE="myjar.jar"
    WIDTH=100 HEIGHT=100>
    then his inner classes are not found by appletviewer.Because he didn't put the inner class files in the jar. Why he didn't put them is another problem.
    There is abosolutely no other explanation I can see.

  • Private inner class

    I have a private inner class , the methods and constructor of this inner class should be private or default ?Please explain me what is the right method and constructor access modifier I should use to private inner classes .

    paulcw wrote:
    I believe that if you make the constructor private, nothing can instantiate it.Not true for an inner class.
    Re the original question: I'm not sure it really matters here, but I've not seen a canonical answer to this.

  • Inaccessible with local variable(non-final) via method local inner class

    Hi All,
    Usually local variables, including automatic final variable live on the stack and objects & instanace variables live on the heap.The contracts for using the method local inner class should allow merely method final variable, not non-final stack variable.
    Can anyone please clarify me ,behind the scene what is actual fact why method inner class should not access the stack(method) variable and only allow final variable?
    Is anything correlated with the stack and heap aspects?
    Thanks,
    Stalin.G

    [email protected] wrote:
    ...behind the scene what is actual fact why method inner class should not access the stack(method) variable and only allow final variable?...explained by dcminter and Jardium in [an older thread|http://forums.sun.com/thread.jspa?messageID=10694240#10694240|http://forums.sun.com/thread.jspa?messageID=10694240#10694240]:
    ...Final variables are copied into inner classes - that's why they have to be declared final; to avoid the developer making an incorrect assumption that the local variable can be modified and have the change reflected in the copy.
    When a local class uses a local variable, it doesn't actually use the variable. Instead, it takes a copy of the value which is contained in the variable at the moment the class is instantiated. It's like passing the variable to a constructor of the class, except that you do not actually declare any such constructor in your code.
    To avoid messy execution flows to be present in a Java method, the Java language authors thought it was better to allow a single value to be present in such a variable throughout all its life. Thus, the variable has to be declared final.
    ...HTH

  • Extending a member inner class

    I have a class
    public class A{
    class InnerClassB{
    Now the question is how to extend the inner class would it be
    class ExtendingInnerClassB extends A.B{
    or else?
    I am not sure anybody knows?

    Regarding inheritance from inner classes you must define your constructor:
    public ExtendedInnerClass(EnclosingClass EC) { EC.super(); }
    why?????
    well
    1. Where is the handle? The handle is an internal thing which is designed to accept the enclosing class. It is something which is not in the programmer's control. when there is an inner class, it is natural that the inner class cannot exist without its outer class. And that is the reason why the instantiation of an inner class is done using new OuterClass().new Innerclass(). U can see that the innerClass object is created based on the outer class object (assuming that the inner Class is not static). I hope that this is clear. Now .. the whole point is how does the compiler know that the Outerclass is the enclosing class? When the above line is compiled, the tricky handle in the inner class is assigned to the Outer class. So any reference henceforth is made based on this handle.
    2. In the Inherited Inner class, there is no way to assoicate the handle in the above manner. Hence we are forcing by calling the super().
    3 Otherwise why not simply create with: new InheritedInnerClass(EnclosingClass)? This is not possible. What if the inherited inner class needs a constructor in the above manner. That is assume that there is a class A. Then if the Inner Class needs the constructor to be InnerClass(A a, EnclosingClass b) for some other purpose, then what judgement can the compiler take? So that answers the question <b>Can't the compiler compile the inherited inner class assuming a handle to the enclosing class and then force an instance to be created using the EnclosingClass.new syntax?</b> Becuase in this case it cant go by any assumption.
    4. Maybe the compiler designers can make some change such that the inherited inner class should have all its constructors beginning with the enclosing object and there should be atleast one constructor. But somehow I feel that it is too much of asking.

  • Inner class standards

    Hi This is kind of a trivial question.
    I know that in Sun's coding standards doc
    see below
    http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
    a class name is supposed to be Capitalized,
    now what about an inner class in no where it says an inner class should or should not be capitalized...

    Given that the Naming Standards you pointed to states nothing about Inner nor Outer classes, but only gives the standard for Classes in general, I would make the inference that both Inner and Outer classes should be capitalized just on this information alone.
    However, the ability to differentiate between a member variable and an inner class, as was demonstrated above, is further reason to follow the same convention for Inner as for Outer classes.

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

  • When Should I use the Inner Classes ?

    When Should I use the Inner Classes ?
    What is the advantage(s) and the disadvantage(s) ?

    When I use innerclasses?
    1) Allmost allways when I need simple owner child behavior.
    2) When I need a behaviour, that is quite small, and used only once, I make it anonymous inner class. For example specialised streams and threads.
    3) Enumerations

  • Jar files and Inner classes..

    I am trying to compile a java source file of a class that has an inner class.. using GNU Make. I am not sure if the .jar file is packing properly, because I get an error :
    Exception in thread "main" java.lang.NoClassDefFoundError: Airport$PortCode
            at Airport.getCode(Airport.java:133)
            at Airport.test1(Airport.java:228)
            at Airport.run(Airport.java:241)
            at Airport.main(Airport.java:255)where Airport.class is the main class and Airport$PortCode is an inner class of it (it is not static and is declared public)
    it works when I use it via "java Airport" but again i get the above error when I run with "airport.jar"
    thanks for you help

    I tried to test it on UNIX, but it replied to my
    commandUh, I am not so lucky to have a UNIX license (and don't see the need). Possibly the find on UNIX is different from GNU's find.
    find: path-list predicate-listUse backticks: The output of the command between backticks is used as the value for the shell variable. Possibly it could be the case that your find program does not allow the omission of the path list, then just make it:
    CLASSES=/home/here/there/project/classes
    `find $CLASSES -name "*.class"`Execute this command and the output of the command executed can be used as a return value.
    -name "*.class"look for all files ending on name.
    You can always do:
    $ man find (man is great)
    or
    $ info find>
    >
    >
    JARCLS    = `find -name "*.class"`

  • ER: Override Methods feature should detect anonymous inner class scope

    Hi,
    Given the following code:
    public class Class1 {
        public static void main(String[] args) {
            Thread t = new Thread() {
                // line 4
            t.start();
    }When the cursor is placed on line 4, activating the Override Method dialog (Source menu), should show Thread methods that I can override, in addition to Object methods. Currently only the method from class Object are being shown. The same treatment should also apply to local method inner classes. This happens with the latest 11g preview 3, and all previous versions.

    Hi,
    I'll file an ER
    Frank

  • [svn] 4130: Remove @private from IXMLNotifiable. as since it is implemented by another class and should appear in ASDoc

    Revision: 4130
    Author: [email protected]
    Date: 2008-11-18 07:36:15 -0800 (Tue, 18 Nov 2008)
    Log Message:
    Remove @private from IXMLNotifiable.as since it is implemented by another class and should appear in ASDoc
    QE Notes: None
    Doc Notes: None
    Bugs: -
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/IXMLNotifiable.as

    My output is listed below. Can I solve the issue by replacing the following line in /etc/postfix/main.cf?
    mydestination = $myhostname,localhost.$mydomain,localhost
    with
    mydestination = $mydomain,localhost.$mydomain,localhost
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    content_filter = smtp-amavis:[127.0.0.1]:10024
    daemon_directory = /usr/libexec/postfix
    debugpeerlevel = 2
    enableserveroptions = yes
    html_directory = no
    inet_interfaces = all
    mail_owner = _postfix
    mailboxsizelimit = 0
    mailbox_transport = cyrus
    mailq_path = /usr/bin/mailq
    manpage_directory = /usr/share/man
    messagesizelimit = 10485760
    mydestination = $myhostname,localhost.$mydomain,localhost
    mydomain = domain.com
    mydomain_fallback = localhost
    myhostname = pinky.domain.com
    newaliases_path = /usr/bin/newaliases
    queue_directory = /private/var/spool/postfix
    readme_directory = /usr/share/doc/postfix
    relayhost =
    sample_directory = /usr/share/doc/postfix/examples
    sendmail_path = /usr/sbin/sendmail
    setgid_group = _postdrop
    smtpdpw_server_securityoptions = gssapi
    smtpdrecipientrestrictions = permitsasl_authenticated,permit_mynetworks,reject_unauthdestination,permit
    smtpdsasl_authenable = yes
    smtpduse_pwserver = yes
    unknownlocal_recipient_rejectcode = 550
    virtualmailboxdomains = hash:/etc/postfix/virtual_domains
    virtual_transport = lmtp:unix:/var/imap/socket/lmtp

  • BUG: Oracle Java Compiler bug with anonymous inner classes in constructor

    The following code compiles and runs just fine using 1.4.2_07, 1.5.0_07 and 1.6.0_beta2 when compiling and running from the command-line.
    It does not run when compiling from JDeveloper 10.1.3.36.73 (which uses the ojc.jar).
    When compiled from JDeveloper, the JRE (both the embedded one or the external 1.5.0_07 one) reports the following error:
    java.lang.VerifyError: (class: com/ids/arithmeticexpr/Scanner, method: <init> signature: (Ljava/io/Reader;)V) Expecting to find object/array on
    stack
    Here's the code:
    /** lexical analyzer for arithmetic expressions.
    Fixes the lookahead problem for TT_EOL.
    public class Scanner extends StreamTokenizer
    /** kludge: pushes an anonymous Reader which inserts
    a space after each newline.
    public Scanner( Reader r )
    super( new FilterReader( new BufferedReader( r ) )
    protected boolean addSpace; // kludge to add space after \n
    public int read() throws IOException
    int ch = addSpace ? ' ' : in.read();
    addSpace = ch == '\n';
    return ch;
    public static void main( String[] args )
    Scanner scanner = new Scanner( new StringReader("1+2") ); // !!!
    Removing the (implicit) reference to 'this' in the call to super() by passing an instance of a static inner class 'Kludge' instead of the anonymous subclass of FilterReader fixes the error. The code will then run even when compiled with ojc. There seems to be a bug in ojc concerning references to the partially constructed object (a bug which which is not present in the reference compilers.)
    -- Sebastian

    Thanks Sebastian, I filed a bug for OJC, and I'll look at the Javac bug. Either way, OJC should either give an error or create correct code.
    Keimpe Bronkhorst
    JDev Team

  • Compiler bug with generics and private inner classes

    There appears to be a bug in the sun java compiler. This problem was reported against eclipse and the developers their concluded that it must be a problem with javac.
    Idea also seems to compile the example below. I couldn't find a bug report in the sun bug database. Can somebody tell me if this is a bug in javac and if there is a bug report for it.
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=185422
    public class Foo <T>{
    private T myT;
    public T getT() {
    return myT;
    public void setT(T aT) {
    myT = aT;
    public class Bar extends Foo<Bar.Baz> {
    public static void main(String[] args) {
    Bar myBar = new Bar();
    myBar.setT(new Baz());
    System.out.println(myBar.getT().toString());
    private static class Baz {
    @Override
    public String toString() {
    return "Baz";
    Eclipse compiles and runs the code even though the Baz inner class is private.
    javac reports:
    Bar.java:1: Bar.Baz has private access in Bar
    public class Bar extends Foo<Bar.Baz>
    ^
    1 error

    As I said in my original post its not just eclipse that thinks the code snippet is compilable. IntelliJ Idea also parses it without complaining. I haven't looked at the java language spec but intuitively I see no reason why the code should not compile. I don't think eclipse submitting bug reports to sun has anything to do with courage. I would guess they just couldn't be bothered.

Maybe you are looking for

  • Error message when burning .img file

    I got this message when trying to burn a .img file: "Unable to burn "disk 4" - the device failed to respond properly . unable to recover or re-try. this happened twice in a row, I suppose that means it wasnt a defective DVD (using verbatim) I am runn

  • Exception while decoding UTF-8 encoded stream

    java.io.UTFDataFormatException java.io.ObjectInputStream$BlockDataInputStream.readUTFSpan(ObjectInputStream.java(Compiled Code)) java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java(Compiled Code)) java.io.ObjectInputStre

  • Placing Images (Screen Caps) for Callouts - Best Practice?

    Illustrator CS6, Windows 7 I'm placing screen captures (screen images from software) in my artwork files to add callouts and create illustrations for a user manual. The machine I'm capturing on has a screen resolution set at 1920 x 1080 (required for

  • I am trying to publish a web site using my own domain. How do I transfer my host to mac from another server?

    I am trying to publish a web site using my own domain. How do I transfer my host to mac from another server?

  • Oracle 10g Release 2 (10.2.0.3)

    Hi, I have a problem while trying to install 10g release 2 (10.2.0.3) on Windows vista . while creating the database , its throws the below error message " Enterprise manager configuration failed due to the following error - Invalid value null for pa