How to install eclipse for java

Eclipse (@ www.eclipse.org) is an open-source Integrated Development Environment (IDE) supported by IBM. Eclipse is popular for Java application development (Java SE and Java EE) and Android apps. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and macOS.

Writing your First Java Program in Eclipse

Step 0: Launch Eclipse
  1. Launch Eclipse by running “eclipse.exe” from the Eclipse installed directory.
  2. Choose an appropriate directory for your workspace, i.e., where you would like to save your files (e.g., c:\myProject\eclipse for Windows) ⇒ Launch.
  3. If the “Welcome” screen shows up, close it by clicking the “close” button next to the “Welcome” title.
Step 1: Create a new Java Project

For each Java application, you need to create a project to keep all the source files, classes and relevant resources.

To create a new Java project:

  1. Choose “File” menu ⇒ “New” ⇒ “Java project” (or “File” ⇒ “New” ⇒ “Project” ⇒ “Java project”).
  2. The “New Java Project” dialog pops up.
    1. In “Project name”, enter “FirstProject“.
    2. Check “Use default location”.
    3. In “JRE”, select “Use default JRE (currently ‘JDK11.0.x’)”. But make sure that your JDK is 1.8 and above.
    4. In “Project Layout”, check “Use project folder as root for sources and class files”.Push “Finish” button.
  3. In “Create module-info.java” dialog, Click “Don’t Create”. (Note: For easier version of Eclipse, you need to use the “Next” Button in the previous step, and uncheck “Create module-info.java file”).
Step 2: Write a Hello-world Java Program
  1. In the “Package Explorer” (left pane) ⇒ Right-click on “FirstProject” (or use the “File” menu) ⇒ New ⇒ Class.
  2. The “New Java Class” dialog pops up.
    1. In “Source folder”, keep the “FirstProject”.
    2. In “Package”, delete the content if it is not empty.
    3. In “Name”, enter “Hello“.
    4. Check “public static void main(String[] args)“.
    5. Don’t change the rest.Push “Finish” button.
  3. The source file “Hello.java” opens on the editor panel (the center pane). Enter the following codes:public class Hello { public static void main(String[] args) { System.out.println(“Hello, world!”); } }
Step 3: Compile & Execute the Java Program
  1. There is no need to compile the Java source file in Eclipse explicitly. It is because Eclipse performs the so-called incremental compilation, i.e., the Java statement is compiled as and when it is entered.
  2. To run the program, right-click anywhere on the source file “Hello.java” (or choose “Run” menu) ⇒ Run As ⇒ Java Application.
  3. The output “Hello, world!” appears on the Console panel (the bottom pane).
NOTES:
  • You should create a NEW Java project for EACH of your Java application.
  • Nonetheless, Eclipse allows you to keep more than one programs in a project, which is handy for writing toy programs (such as your tutorial exercises). To run a particular program, open and right-click on the source file ⇒ Run As ⇒ Java Application.
  • Clicking the “Run” button (with a “Play” icon) runs the recently-run program (based on the previous configuration). Try clicking on the “down-arrow” besides the “Run” button.
  • references:www3.ntu.edu.sg
Design a site like this with WordPress.com
Get started