Downloading and Installing JDK
This page shows how to download and install the latest version of the Java Development Kit (JDK). Read the instructions carefully to set the "classpath" mentioned in Step 3. Once JDK has been installed, you can write a simple Java program using an editor such as notepad and run it from a command prompt. Alternatively, Java programs can be written using an Integrated Development Environment (IDE) such as NetBeans, described below.
5. JDK 11 Launch Single-Source-File New Feature
In JDK 11, you can compile/run a single-file program in one step, without explicit compilation.
- Write a "
Hello.java" (see previous section).
- Delete "
Hello.class", if it exists.
- You can compile/run "
Hello.java" in one command as follows:
// Change directory to the directory containing Hello.java // Compile and Run java Hello.java
- This is applicable to single source-file only.
- No need to use
javacto compile the program.
- It compiles in memory (without producing a
.classfile), and run.
- This feature is introduced for beginners to learn Java, and for professionals to test a Java feature.
- The filename and classname need not be the same.