AppletFailures

Download Report

Transcript AppletFailures

If your Java applet does not run
Prashanth Sanagavarapu
Problems with applets?
• Many students face problems while running
Applets from AFS .
• some of the common Problems are…
• Applet Not initiated
• Applet loading Failed
• Source not found.
Problems with applet? (cont..)
• (Imaginary) messages from my mail box :
Dear Prof,
My applet works on my laptop but does not work on
web. Please grade my work through screen shot or I
will show it class on my laptop.
• Prof Replies :
Dear student,
This course is “Java and the Web” not “Java on Your
Laptop.”
Failed Loading
The most common problem you see….
This means your applet failed!
Files in Same Folder?
• Did you keep the class files and html document containing the
class file in same folder?
• If you don’t have them in the same folder, it is harder to write the
code to get them to load. (It can be done.)
Ex :
Use single folder to store all related files as above
Backslash in URL
• One of the most common Error Messages is
Loading Applet Failed !!
• Do you have a backslash \ instead of a / in your URL?
(Put mouse pointer over link, look at bottom of screen.)
correct form (bottom of browser):
http://web.njit.edu/~sss49\java.htm
will work in IE on Windows, but not on other browsers, and will not work
on AFS or any Unix version.
NetBeans or Eclipse Setup
• When you see your applet running on Laptop
and it doesn’t run on the Web, especially if you are
using Eclipse or Netbeans, declare all the classes in
the default package. Do not use a package name.
Runningapplet will
work on web
This HelloWorld Applet is
harder to transfer to Web
Small changes in file names
• Another common mistake is to use
different case for the class name in your
html code.
Ex: If HelloWorld.Class is the class file and you misprint it as
Helloworld.class in html code then applet can not find the source and
fails to run.
Check the “W”
HelloWorld, Helloworld, and helloworld are three different names to
Unix and most browsers, although they are the same name to Windows
and Internet Exploder.
Using awt and Swing
components
• There is a special version of applet to use when you are
using abstract windows toolkit and Swing components—the
JApplet class.
• JApplet is volatile. The current version (JDK 1.5) has
limited serializability and will be incompatibly changed in
future versions. But it is still the best version to use with a
LayoutManager.
• See the tutorial on “How to Make Applets” in the Java
Tutorial and the documentation for the javax.swing
interface RootPaneContainer.
Key resource: Web Board
If there are any other problems other than these,
Please post them on Web Board. This will help you
and others.
Web Board’s Tech support can be life saver at the
last minute before exams & project due dates.

Source of information
• My personal experience from doing Java
homework in CIS 602—Prashanth
Sanagavarapu.