To get a Java compiler, download a Java Development Kit (JDK) from its vendor and verify the installation in a terminal. Downloading an IDE for Java is optional: an IDE adds an editor, debugging, and project tools, while the JDK supplies the compiler and runtime used to build and run the program.
Choose and Install a JDK
A Java compiler download is normally a JDK distribution rather than a standalone compiler. The JDK includes javac, which compiles source code into class files, and java, which starts the Java runtime. A runtime-only package may run applications but does not provide the development tools required here.
Choose the version required by your project, course, or build configuration. For a new project without a fixed requirement, a currently supported long-term support release is a practical choice. Check the vendor’s support schedule and licensing terms for your intended use. Select the operating system and processor architecture that match your machine, such as Windows x64 or macOS ARM64.
For example, Eclipse Adoptium’s Temurin releases page offers JDK packages by version and platform. Download the JDK package from the vendor, follow its installation instructions, and note the installed JDK directory. Use the vendor’s published checksum or signature instructions when verifying the installer. For a download of Java’s compiler through a managed package source, an organization’s approved repository may be preferable when it supplies the approved distribution and updates.
Java IDE Download and Project Setup
A Java IDE download gives you a development workspace; it still needs a project JDK. When downloading an IDE for Java, use its vendor’s site or your organization’s approved package source. An IDE may offer to install one or use an existing installation. If you already installed the required JDK, point the project to its home directory, not the bin subdirectory.
For example, in IntelliJ IDEA open File → Project Structure → Project, then select the project SDK. If it is not listed, add a JDK from disk and select the installed JDK home. Set the project’s language level to match its requirements. A module or build tool can have its own JDK configuration, so inspect that setting too if a project uses a different version than expected. JetBrains documents these options in its SDK guide.
Verify and Run a Small Program
Open a new terminal after installation and run:
javac -version
java -version
Both commands should print version information. If the shell cannot find javac, add the JDK’s bin directory to your PATH using your operating system’s environment settings, then open a fresh terminal. JAVA_HOME, when needed by a build tool, should point to the JDK home rather than bin. Make sure both commands resolve to the intended installation when multiple JDKs are present.
To download a Java compiler is only the first step; compile and run an actual file to check the full path. Create Hello.java in a new directory:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
In that directory, run:
javac Hello.java
java Hello
The first command creates Hello.class; the second should print Hello, Java!. The public class name and source filename must match, including capitalization. Run the class by name without the .class extension. The default classpath normally includes the current directory, though an explicitly configured classpath can change that.
If javac is missing while java works, the shell may be finding a runtime or a different installation. Check the resolved command paths and move the intended JDK’s bin earlier in PATH. If compilation works but running reports an unsupported class version, compare the compiler and runtime versions and use a compatible runtime or the project’s required compilation target.
