• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BasicsDemo error message

 
Brent King
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class BasicsDemo {
public static void main(String[] args) {
int sum = 0;
for (int current = 1; current <= 10; current++) {
sum += current;
}
System.out.println("Sum = " + sum);
}
}

The output from this program is:

Sum = 55

I compiled the following prog. and got the following message in appletviewer: applet not initialized.

This was the following message at the C Prompt:
C:\Program Files\Java>appletviewer BasicsDemo.html
java.lang.ClassCastException: BasicsDemo
at sun.applet.AppletPanel.createApplet(AppletPanel.java:710)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:639)
at sun.applet.AppletPanel.run(AppletPanel.java:319)
at java.lang.Thread.run(Thread.java:595)

Thanks Brent
 
Henry Wong
author
Marshal
Pie
Posts: 20831
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Appletviewer is used to run/test Applets. Your program is not an Applet. You are getting a cast exception because your class do not extend the java.applet.Applet class.

Henry
 
Brent King
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I am getting application and applet mixed up.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic