aspose file tools*
The moose likes Beginning Java and the fly likes BasicsDemo error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BasicsDemo error message" Watch "BasicsDemo error message" New topic
Author

BasicsDemo error message

Brent King
Greenhorn

Joined: Apr 18, 2005
Posts: 8
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
Sheriff

Joined: Sep 28, 2004
Posts: 18141
    
  39

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Brent King
Greenhorn

Joined: Apr 18, 2005
Posts: 8
Sorry I am getting application and applet mixed up.
 
wood burning stoves
 
subject: BasicsDemo error message
 
Similar Threads
applet not initialized
GPA Program ......... Error
Incrementing by 1
basic doubt!!
Simple question on Applet