Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet not initiated

 
biruk naz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
my applet runs good in applet viewer but when i use html to run on the internet explorer there is an error on the status bar sayng "applet not initiated " and also "loading applet failed".
Thank you all 4 your help.

The pplet tag in the html code is:
<APPLET codebase="classes" code="appletproject/Player.class" width=350 height=200></APPLET>

The applet code is:

[ June 24, 2008: Message edited by: biruk naz ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The first thing to do when debugging applet problems is to check whether there are exceptions or error messages in the Java Console; I suspect there are some in this case.

In particular, is the Player class in a directory called "classes/appletproject" that's in the same directory as the HTML file? Also, the code attribute takes a fully qualified class name - that means it can contain dots, but not slashes.

In the future, please UseCodeTags when posting code of any length. It's unnecessarily hard to read as it is.
 
biruk naz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thank you for your help

In the java console there is some error report but i can't understand it.
The player.class file is in the directory classes/appletproject/player.class.
" code attribute takes a fully qualified class name - that means it can contain dots, but not slashes." sorry i didn't get this statement, please could you explain me what mistake did i make on the code attribute.

Thank you
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the full stack trace of the error. Otherwise we can't tell what really is going wrong.

Is the "classes" directory in the same directory as the HTML file that contains the applet?

code attribute takes a fully qualified class name - that means it can contain dots, but not slashes.

A fully qualified class name contains all the packages in addition to the class name, e.g. "appletproject.player". Note that it contains a dot (between package name and class name), but no slash (like the one in the code attribute you posted). So you need to fix that.
 
biruk naz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,The HTML file is in the same directory with the classes directory.
I have changed the slashes with dots "appletproject.player.class" now the status bar of the browser is showing "Loading Java Applet Failed..."

The stack trace of the error from the java console is:

java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Thank you again for your help.
[ June 24, 2008: Message edited by: biruk naz ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add all jar files that the applet uses to the applet classpath; in this case you're missing the jdesktop classes. You'd use the archive attribute of the applet tag for this.
 
biruk naz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again for your help

But sorry i dono what jar files are(are these other classes used by the applet?) and if you don't mind can you give me some examples.

For example i have a class called PlugIn that is used by the applet, what do i have to do with this class in the applet tag? what do i have to assign for the archives attribute? I think you don't mind if my question is too ambiguous.

Thank you.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To learn about the basics of applets, head for the Applet FAQ. The sections http://faq.javaranch.com/java/AppletsFaq#basics and http://faq.javaranch.com/java/AppletsFaq#tag point you to further material.

You don't need to add other class files (like Plugin) to the applet tag - only the class that extends JApplet needs to be mentioned in the "code" attribute.

But other classes used by the applet typically come in jar files. Those need to be mentioned in the "archive" attribute. The link mentioned above shows you how to do this. You must have the JDesktop jar file somewhere, because it would have been needed when you compiled the applet.
 
Norm Radder
Ranch Hand
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do any of the other class files have import statements in them that are different from what you posted above? Are any of them similiar to the path:
org/jdesktop/layout/GroupLayout?

What jar files are you using to compile all the different classes? For example: OutputLine
All the jar files used in compiling MUST be available to the Java jvm for it to be able to load the classed used.

Are the Appletviewer and the java plugin for IE at the same level of Java?
[ June 24, 2008: Message edited by: Norm Radder ]
 
biruk naz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Other classes used by the applet such as PlugIn and OutputLine are on the same file, i.e, player.java but after compiling there are different .class files such as plugin.class, outputline.class and player.class(the applet) which file(s) do i have to change to JAR file.

Thank you all
 
biruk naz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Norm

What do you mean by "Are the Appletviewer and the java plugin for IE at the same level of Java?"
Sorry I dono anything about a java plugin and level of Java.
 
Norm Radder
Ranch Hand
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are different releases of java that are not compatible. I don't think that is the problem, but one never knows.

The error message from the console stated that the jvm could not find a class that was present when some part of your application was compiled. That part might not be yours but rather comes from your IDE or from another version of java that is different from the one that you are using to execute the program in IE.

Do a search on your system for any file(such as jar or class) that contains the string: jdesktop
That was part of the path to the class not found when you tried to execute the program. See error message you posted.

If you find it in a jar file, you need to add the jar file to the path pointed to in the Archive= attribute of the <APPLET tag.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic