Step 1: Install Java Development Kit (JDK)

  1. Download JDK:
    • Visit the official Oracle JDK download page or an alternative like OpenJDK.
    • Choose the appropriate version for your operating system (Windows, macOS, Linux) and download the installer.
  2. Install JDK:
    • Follow the installation instructions provided by the installer.
    • During installation, set the Java Home path. This is the directory where the JDK is installed. Note this path; you’ll need it later.
  3. Verify Installation:
    • Open a terminal or command prompt.
    • Type the following command and press Enter:
java -version
javac -version

Step 2: Choose an Integrated Development Environment (IDE)

Choose an IDE based on your preference. Two popular choices are Eclipse and IntelliJ IDEA.

For Eclipse:

  1. Download Eclipse:
    • Visit the official Eclipse download page.
    • Choose the Eclipse IDE for Java Developers package and download the installer.
  2. Install Eclipse:
    • Run the installer and follow the on-screen instructions.
  3. Configure Eclipse:
    • Open Eclipse.
    • Set the workspace location (where your projects will be stored).

For IntelliJ IDEA:

  1. Download IntelliJ IDEA:
    • Visit the official IntelliJ IDEA download page.
    • Download the Community (free) or Ultimate (paid) edition.
  2. Install IntelliJ IDEA:
    • Run the installer and follow the installation instructions.
  3. Configure IntelliJ IDEA:
    • Open IntelliJ IDEA.
    • Complete the initial setup wizard, including configuring the JDK.
    • Set the project directory.

Step 3: Configure IDE with JDK

Eclipse:

  1. Open Eclipse.
  2. Go to Window > Preferences.
  3. In the Preferences window, navigate to Java > Installed JREs.
  4. Click “Add External JARs” and select the jar files in your JDK’s lib directory.
  5. Click “Apply and Close.”

IntelliJ IDEA:

  1. Open IntelliJ IDEA.
  2. Go to File > Project Structure.
  3. Under Project, ensure that the Project SDK is set to the installed JDK.
  4. Click “OK” to apply changes.

Step 4: Create a Java Project

  1. Open your chosen IDE.
  2. Create a new Java project.
  3. Write a simple Java program to test your setup.

For Eclipse:

  1. Open Eclipse.
  2. Go to File > New > Java Project.
  3. Enter a project name (e.g., HelloWorld) and click “Finish.”
  4. Inside the src folder of your new project, create a new Java class:
    • Right-click on the src folder.
    • Choose New > Class.
    • Enter a class name (e.g., HelloWorld) and check the option to include the public static void main(String[] args) method.
    • Click “Finish.”
  5. In the editor, replace the default code in HelloWorld.java with the following:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
  1. Save the file (Ctrl + S or Cmd + S).
  2. Right-click on the HelloWorld class file in the src folder.
  3. Choose Run As > Java Application.

You should see the output “Hello, World!” in the console at the bottom of the Eclipse window.

For IntelliJ IDEA:

  1. Open IntelliJ IDEA.
  2. Click on Create New Project.
  3. Choose Java on the left sidebar, and click Next.
  4. Enter a project name (e.g., HelloWorld) and click Finish.
  5. Inside the src folder of your new project, create a new Java class:
    • Right-click on the src folder.
    • Choose New > Java Class.
    • Enter a class name (e.g., HelloWorld) and check the option to include the public static void main(String[] args) method.
    • Click OK.
  6. In the editor, replace the default code in HelloWorld.java with the following:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
  1. Save the file (Ctrl + S or Cmd + S).
  2. Right-click on the HelloWorld class file in the src folder.
  3. Choose Run 'HelloWorld.main()'.

You should see the output “Hello, World!” in the Run window at the bottom of the IntelliJ IDEA window.