Java Basic

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

 

How to Install Eclipse IDE 2021-12 for Java Developers


1.1  How to Install Eclipse on Windows
Step 0: Install JDK
To use Eclipse for Java programming, you need to first install Java Development Kit (JDK).
Read "How to Install JDK for Windows".
Step 1: Download
Download Eclipse from https://www.eclipse.org/downloads/packages/. Choose "Eclipse IDE for
Java Developers" and "Windows x86_64" (e.g., "eclipse-java-2021-12-R-win32-x86_64.zip" -
about 313MB) ⇒ Download.
Step 2: Unzip
To install Eclipse, simply unzip the downloaded file into a directory of your choice (e.g., "c:\
myProject").
I prefer the zip version, because there is no need to run any installer. Moreover, you can simply
delete the entire Eclipse directory when it is no longer needed (without running any un-installer).
You are free to move or rename the directory. You can install (unzip) multiple copies of Eclipse
in the same machine.

2.  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.
a. In "Project name", enter "FirstProject".
b. Check "Use default location".
c. In "JRE", select "Use an execution environment JRE (JavaSE-17). Make sure that
your JDK is 11 and above.
d. In "Project Layout", check "Use project folder as root for sources and class files".
e. In "Module", UNCHECK "Create module-info.java" file.
Push "Finish" button.
IF "Create module-info.java" dialog appears, Click "Don't Create".
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.
a. In "Source folder", keep the "FirstProject".
b. In "Package", leave it EMPTY. Delete the content if it is not empty.
c. In "Name", enter "Hello".
d. Check "public static void main(String[] args)".
e. Don't change the rest.
Push "Finish" button.
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).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy