//********************************************************************
// Einstein.java Author: Lewis/Loftus
//
// Demonstrates a basic applet.
//********************************************************************
import javax.swing.JApplet;
import java.awt.*;
public class Einstein extends JApplet
{
//-----------------------------------------------------------------
// Draws a quotation by Albert Einstein among some shapes.
//-----------------------------------------------------------------
public void paint (Graphics page)
{
page.drawRect (50, 50, 40, 40); // square
page.drawRect (60, 80, 225, 30); // rectangle
page.drawOval (75, 65, 20, 20); // circle
page.drawLine (35, 60, 100, 120); // line
page.drawString ("Out of clutter, find simplicity.", 110, 70);
page.drawString ("-- Albert Einstein", 130, 100);
}
}
Error: Main method not found in class Einstein, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
How can I fix this?
You need to add the entry main
method to your class if you want to run it like as an application java:
public static void main(String[] args) {
...
But if you want to run it like a Applet application use run java applet.
You need an init(){} function. Also from what i've seen on the web people use 'Applet' not JApplet. I don't recommend making java applets as of chrome no longer supports plugins like Java and Unity Web Player.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.