Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written primarily in Java and can be used to develop applications in Java and, by means of various plug-ins, other languages including C, C++, COBOL, Python, Perl, PHP, Scala, Scheme and Ruby (including Ruby on Rails framework). The IDE is often called Eclipse ADT for Ada, Eclipse CDT for C/C++, Eclipse JDT for Java and Eclipse PDT for PHP.
Start Eclipse
To start Eclipse double-click on the file eclipse.exe in your installation directoryCreate project
Select from the menu File -> New-> Java project. entersuch as "MyTestProject"
Create package
Create now a package. A good convention is to use the same name for the top package as the project. Create therefore the packageas "MyTestProject"
Create Java class
Right click on your package and select New -> Classname it as Frame2
In Frame2.java window type:
import java.awt.*;
import java.awt.event.*;
public class Frame2 extends Frame {
private Closer Handler;
Frame2 () {
Handler = new Closer ();
setTitle ("Frame Example");
setSize (300,120);
addWindowListener (Handler);
show ();
}
public static void main (String args[]) {
Frame f;
f = new Frame2 ();
}
}
class Closer extends WindowAdapter {
public void windowClosing (WindowEvent event) {
System.exit (0);
}
}
Run your project in Eclipse
Now run your code. Right click on your Java class and select Run-as-> Java applicationYou see a frame pop-up.
Run your Java program outside Eclipse (create jar file)
To run your Java program outside of Eclipse you need to export it as a jar file. Select your project, right click on it and select "Export".such as "Frame2.jar"
No comments:
Post a Comment