How to compile and run Java program in CMD | in windows 10
Learn to Run Java Programs:
Compile and run java code in windows 10 using CMD.
Download and install java latest version
- Running a Java program on Windows 10 is a straightforward process that involves a few simple steps.
- First, you need to ensure that you have the latest version of Java installed on your computer. you can download from official Oracle website. or Download from link below.
- Once you have installed Java, you can write your Java code in a text editor such as Notepad or Notepad++ and save it with a .java extension.
Locate CMD to JAVA file
- To run the program, you need to open the command prompt by typing "cmd" in the Windows search bar and navigating to the directory where your Java file is saved using the "cd" command.
- Once you are in the directory, you can compile the Java file using the "javac <filename>.java" command. This will create a new file with a .class extension if there are no errors in your code.
- To run the program, you need to open the command prompt by typing "cmd" in the Windows search bar and navigating to the directory where your Java file is saved using the "cd" command.
- Once you are in the directory, you can compile the Java file using the "javac <filename>.java" command. This will create a new file with a .class extension if there are no errors in your code.
Running and compiling the code:
- To run the program, you need to type "java <filename>" in the command prompt and press Enter. Replace <filename> with the name of your Java file without the .java extension. The program should now run, and any output will be displayed in the command prompt.
- Commands for Compile: javac filename.java
- Commands for Run: java filename.java
Overall, running a Java program on Windows 10 is a simple process that can be accomplished with a few easy-to-follow steps. With the right tools and some basic knowledge of Java programming, you can easily create and run Java programs on your Windows 10 machine.
- To run the program, you need to type "java <filename>" in the command prompt and press Enter. Replace <filename> with the name of your Java file without the .java extension. The program should now run, and any output will be displayed in the command prompt.
- Commands for Compile: javac filename.java
- Commands for Run: java filename.java
How to run Java program in Macintosh:
- Download and Install the latest version of Java JDK on your Mac . You can download the Java SE Development Kit (JDK) from the official Oracle website.
- Once installed, open a text editor such as TextEdit or Sublime Text.
- Write your Java code in the text editor and save the file with a .java extension.
- Terminal open and Finder go to Applications --> Utilities --> Terminal.
- Navigate to the directory where your Java file is saved by using the "cd" command.
- Once you're in the directory, compile the Java file using the command "javac <filename>.java" where <filename> is the name of your Java file.
- If there are no errors found in your written code, file with a.class extension will be created.
- To run your program, type "java <filename>" in the Terminal and press Enter. Replace <filename> with the name of your Java file without the .java extension.
- Your program should now run and any output will be displayed in the Terminal.
- That's it! You have successfully run a Java program on Macintosh.
- Download and Install the latest version of Java JDK on your Mac . You can download the Java SE Development Kit (JDK) from the official Oracle website.
- Once installed, open a text editor such as TextEdit or Sublime Text.
- Write your Java code in the text editor and save the file with a .java extension.
- Terminal open and Finder go to Applications --> Utilities --> Terminal.
- Navigate to the directory where your Java file is saved by using the "cd" command.
- Once you're in the directory, compile the Java file using the command "javac <filename>.java" where <filename> is the name of your Java file.
- If there are no errors found in your written code, file with a.class extension will be created.
- To run your program, type "java <filename>" in the Terminal and press Enter. Replace <filename> with the name of your Java file without the .java extension.
- Your program should now run and any output will be displayed in the Terminal.
- That's it! You have successfully run a Java program on Macintosh.
Post a Comment