If you are just starting to learn Java, this basic guide will help you start running the Java application from the Command Prompt in Windows 10/11.
Installing the Java Development Kit (JDK) in Windows
Before you can run a Java program on your computer, you’ll need to have a dedicated compiler installed. This comes within the Java Standard Edition Development Kit (JDK). It’s an essential tool for developing in Java on any platform. The JDK is not the same as the Java Runtime Environment (JRE), which you’ll already have installed if you’ve ever used a Java application on your machine. Note: if you have just simple use for Java software, make sure you do not download the “Java SE Development Kit for Java SE subscribers,” which is on the same download page. If you wish to use Java’s JRE installation for Microsoft Windows, it has been moved to another page.
Running a Java Program From the Command Prompt
Note: the Java Runtime Environment (JRE) folder also contains a “bin” folder but doesn’t hold the Java compiler. If you get errors around the compilation, make sure you’re using the correct directory path. You’ll see the program run within the Command Prompt window, but there’s one more task you can do to make sure your Java program runs smoothly: set your path.
Setting a Permanent PATH
The above command doesn’t set your Java compiler PATH permanently. It sets the environment variable for that session, but that change will be wiped away when you close the Command Prompt session. Setting your Java compiler PATH permanently can come in handy if you want your compiled Java programs to run smoothly after a PC reboot. This helps launch the requested programs quickly from the Command Prompt window (or a third-party software like Eclipse). Follow the steps below to change your PATH variable for all future sessions. This article featured a simple Java program, but you can initiate almost any Java program from the Command Prompt. The procedure is straightforward regardless of the nature of your program. Image credit: WrightStudio via AdobeStock. All screenshots by Sayak Boral. In the “Advanced Security” settings for Java, change the “Owner” from “System” to whatever user account you have used to log in to the device. You can determine the correct name from “Check names.” Just enter the text, such as “Desktop,” “Administrator,” or “Users,” to enable full permissions to the folder. Click “OK” and save the changes.
Java came before Javascript. It was founded by Sun Microsystems in 1991-1995. Javascript was founded later by Netscape, an old browser company. Basically, Javascript is a very lightweight version of Java and still commonly used in browsers.Java is a compiled program, whereas Javascript is interpreted.Java is a static typed program, whereas Javascript is dynamically typed.Java uses classes, and Javascript uses prototypes.