Skip to content

ChaitanyaShah26/Java-Programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 

Repository files navigation

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.

Overview

Setting up Java

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

How to Write -> Compile -> Execute Java program?

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.java

Step-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 ClassName

Step-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.

How to set path on command prompt?

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

Image reference for Global Path setting.

Content of Repository

🌟🌟

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! 😊

@ChaitanyaShah26

About

Concepts and fundamentals of learning Java Programming with practice codes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages