Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error when using JApplet in appletviewer in Linux  RSS feed

 
Jeff Wang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear my friends,
I am new to Swing. I follow the text book and type the following code:

import java.swing.*;
import java.awt.Graphics;
public class MyFirstApplet extends JApplet
{
public void paint(Graphics g)
{
g.drawString("To climb a ladder, start at the bottom rung", 20, 90);
}
}
The file is compiled successfully.
And then I create a html file as following code:

When I use appletviewer to see the MyFirstApplet.html, I get the following error:
[root@best2 Work]# appletviewer MyFirstApplet.html
java.lang.ClassCastException: can't cast `MyFirstApplet' to `java/applet/Applet'at kaffe.applet.AppletViewer.createApplet(AppletViewer.java:302)
at kaffe.applet.AppletViewer.<init>(AppletViewer.java:261)
at kaffe.applet.AppletViewer.main(AppletViewer.java:418)

My path contains /usr/java/jdk1.3.1_01/bin:/usr/java/jdk1.3.1_01/jre/bin
I do not specify the CLASSPATH. I use JDK1.3.1_01 and my OS is Redhat 7.2.
The same code works in Microsoft Windows. Please help me.
Thank you very much,
Jeff Wang

[This message has been edited by Nathan Pruett (edited December 10, 2001).]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may have the 1.3.1 Sun JDK in your path, but according to the error message you are running appletviewer from the Kaffe JVM. Check the version of Kaffe you are running and see if it supports Swing. It may be an older version that does not.

-Nate
 
Jeff Wang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Nate. You do give me a big favor. I check the reason why my html file does not invoke the appletviewer from JDK directory, and I find if I put my java directory in the very beginning of the $PATH, the problem is solved.
The applet works fine although I still get a lot of messages from the console like the following:
Font specified in font.properties not found [--symbol-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific]

Thank you for your help, and if you have time, could you help me to solve the message problem?
Chi-Fu
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a posting about your problem over in the Linux/Unix forum. I've seen these messages on just about every Java program running on Linux/Solaris/Unix that I have ever seen. You either need to update your system fonts, update the fonts that the JDK can get to, or edit your font.properties file. I've never gone to the trouble of fixing it before because it was never that big of a problem...

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!