Configuring a Java Development Kit and Crafting Your Initial Application

The Java ecosystem revolves around a set of well-defined components that enable both execution and development. At its core lies the Java Virtual Machine (JVM), an abstract computing engine that interprets bytecode and provides memory management along with automatic garbage collection. The Java Runtime Environment (JRE) bundles the JVM with essential libraries, forming a minimal platform solely for running Java programs. For building software, the Java Development Kit (JDK) extends the JRE by including tools like javac (the compiler), javadoc, and various debugging utilities. In essence, the JDK encompasses the JRE plus development tooling.

Obtaining and Installing the JDK

Downloads are available from Oracle’s official site. Choose a stable release (for example, JDK 17 LTS) to maintain compatibility across projects. Run the installer and note the installation directory; this path is needed later for environment configuration.

Setting Environment Variables

To access Java commands globally from the terminal, define the JAVA_HOME variable pointing to the JDK folder, then update the system PATH.

  1. Open System Properties → Advanced → Environment Variables.
  2. Under System variables, create JAVA_HOME with the JDK installation path.
  3. Locate Path among system variables, click Edit, and add two entries:
    • %JAVA_HOME%\bin
    • %JAVA_HOME%\jre\bin
  4. Use the Move Up button to place these entries near the top, ensuring they take priority.

After saving, open a new terminal and validate the setup with java -version and javac -version.

Selecting an Editor or IDE

Any text editor suffices for writing .java files, but an Integrated Development Environment accelerates productivity. IntelliJ IDEA Community Edition is02, popular choice; other alternatives include Eclipse and VS Code with Java extensions. Ensure the IDE is configured to use the JDK you installed.

Writing and Executing a Basic Program

Create a file named HelloWorld.java. Source files must have the .java extension, and the filename must exactly match the public class name contained within. Class identifiers can include alphanumeric characters, underscores, and dollar signs, starting with a letter, underscore, or dollar sign.

public class HelloWorld {
    // Program entry point
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}

Indentation improves readability but is not syntactically required.
Compile the code using javac:

javac HelloWorld.java

If compilation succeeds, a HelloWorld.class file containing bytecode is produced. Then run the program with:

java HelloWorld

Note that you omit the .class extension when invoking the JVM.

Comments in Java

  • Single‑line: // comment
  • Multi‑line: /* comment */
  • Documentation: /** doc comment */

Aim for %30 of your code to be commented for clarity. IDE shortcuts (e.g., Ctrl+/) streamline toggling single‑line comments.

Naming Conventions

Adopt descriptive names that reveal intent. Standard conventions help maintain consistency:

  • Class names: PascalCase – each word capitalized, e.g., CustomerOrder.
  • Variables and methods: camelCase – first word lowercase, subsequent words capitalized, e.g., calculateTotalPrice().
  • Constants: UPPER_SNAKE_CASE – all letters uppercase with underscores, e.g., MAX_RETRY_COUNT.
  • Avoid using Java reserved kyewords (e.g., class, void, static) as identifiers.

Tags: java JDK Environment Setup beginners JVM

Posted on Sat, 03 Oct 2026 16:36:31 +0000 by DotSPF