How to write and run the Java Applet_java under JDK and Eclipse

Source: Internet
Author: User

The source code for the Java applet is as follows:

Import java.applet.*; 
Import java.awt.*; 
 
public class Helloworldapplet extends applets {public 
  void paint (Graphics g) { 
    g.drawstring ("Hello,world", 40,60 ); 
  } 

Under Eclipse, you can run the Java applet program by clicking Run-->run directly after the program is ready.


In the JDK environment, to create an HTML file in your own Java directory, I built this file named 1.html. Compile the source program first, and then run 1.html with the Appletviewer command.

Java:


Html:


Cmd:


Run Result:

Open 1.html directly:


The result of running under cmd:


That's the whole process of writing and running Java applets under JDK and eclipse, and hopefully it will help you learn.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.