• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Error when using JApplet in appletviewer in Linux

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic