Java is general purpose, object oriented language developed by Sun Microsystems of USA in 1991. Earlier Java was called Oak by James Gosling (one of the inventors of Java) which was later renamed as Green and then finally named as Java. Java is the first language which gives us facility of the multi threading type of the programming.
- Setting up Java
- How to Write -> Compile -> Execute Java program?
- How to set path on command prompt?
- Content of Repository
Before starting with Java make sure to setup Java on your local machines. Follow the below steps to get going:
Step-1: Download & Install latest version of jdk from the below link ππ»
https://www.oracle.com/in/java/technologies/downloads/
javac- Java compiler
java- Java Interpreter
Step-2: Create a text file and save it as ClassName.java
Step-3: Compile the .java file from command line. This generates a ClassName.class file in the same directory
Step-4: Execute the class file
Refer the video or follow the below steps to run a Java program in Command Prompt:
How.to.write.compile.and.execute.Java.file.mp4
Step-1: Open the Command Prompt (CMD) or Terminal.
Step-2: Navigate to the directory where your Java source file (with a .java extension) is located using the "cd" command.
Step-3: Compile the Java file into bytecode using the "javac" command followed by the filename with the .java extension.
For example,
javac ClassName.javaStep-4: Once the compilation is successful, run the program using the "java" command followed by the class name (without the .class extension).
For example,
java ClassNameStep-5: The Java program will now execute, and you will see the output (if any) in the Command Prompt.
Note
Make sure that you set path before compiling the java file. Without set path command line won't recognize javac.
Method 1: In this method, you need to set the path every time you open command prompt.
To set path you need to copy the bin location of JDK Installtaion directory.
Step-1: Determine the location of your Java Development Kit (JDK) installation directory.
Step-2: Open the Command Prompt (CMD).
Step-3: Set the path to your JDK Installation bin folder
set path = "(Bin Location)"Step-4: Compile using javac and execute using java commands.
Method 2: In this method, we set the global path variable to JDK bin location and hence we do not need to set path everytime we open CMD before executing java program.
Step-1: Go to properties from This PC
Step-2: Click on Advanced System Settings
Step-3: Select Environment Variables
Step-4: Click New..
Step-5: Set Variable name as path and Variable value as locaion of JDK bin
Click OK
If you find this repository helpful, consider giving it a star β and do share with others who could use this repository to the fullest!
Let's learn and grow together! π
Enjoy coding and happy learning! π

