First java applet program

Before getting started, you'll need a compiler for Java, so that you can translate source code into something executable. You could, for example, download the Java Software Development Kit (abbreviated as JDK), which includes a compiler, utilities, example applets, and documentation. Be sure to get the JDK and not the JRE (Java Runtime Environment) -- the former allows you to compile Java programs, the latter only allows you to run them.
Many programmers also like to have an IDE (integrated development environment - a program that allows you to edit source code within a window and press a single button to compile and run your code) to help them work. If you download the JDK with Netbeans from Oracle's website, you'll have an IDE included with the development kit. Another popular IDE for Java is Eclipse (to work with Eclipse, it's probably best to first install the JDK, and next install Eclipse, so that Eclipse can detect the presence of the JDK during its installation process). Personally, I don't use any IDE, so I install the JDK without Netbeans or Eclipse, and run the Java compiler directly on a command line


Compile : Javac applet_name.java
Run       : appletviewer applet_name.java


Sample Program FirstApplet.java


import java.applet.*;
import java.awt.*;
/*<APPLET CODE="FirstApplet" WIDTH="800" HEIGHT="500">
</APPLET>*/
public class FirstApplet extends Applet
 {
   public void paint(Graphics g)
    {
      g.drawString("Welcome in Java Applet.",100,200);
   }
}
Output 

javac FirstApplet.java
appletviewer FirstApplet.java 


first running of applet program

0 comments:

Post a Comment

 

learn java programming Copyright © 2011-2012 | Powered by appsackel.org