Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

Java Get Started


Java Install

Some PCs might have Java already installed.


To check if you have Java installed on a Windows PC, search in the start bar for Java or type the following in Command Prompt (cmd.exe):

C:\Users\Your Name>java -version

If Java is installed, you will see something like this (depending on version):

java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)




Java Quickstart


Step 1: Install Java Development Kit (JDK)

  1. Visit the Java SE Downloads page on the Oracle website.
  2. Download the JDK installer for your operating system (Windows, macOS, or Linux).
  3. Run the installer and follow the on-screen instructions to install the JDK.

Step 2: Set Up Environment Variables (Optional but Recommended)

  1. Set the JAVA_HOME environment variable to the directory where you installed the JDK.
  2. Add the JDK's bin directory to your system's PATH variable to access Java commands from the command line.

Step 3: Write Your First Java Program

  1. Open a text editor and create a new file named HelloWorld.java.
  2. Write a simple "Hello World" program in the file:
          public class HelloWorld {
            public static void main(String[] args) {
                System.out.println("Hello, world!");
            }
        }
         

Step 4: Compile and Run Your Program

  1. Open a command prompt or terminal.
  2. Navigate to the directory where you saved HelloWorld.java.
  3. Compile the program using the javac command:

javac HelloWorld.java


  1. If the compilation is successful, a HelloWorld.class file will be generated.

  2. Run the compiled program using the java command:

java HelloWorld

Congratulations, you have written and executed your first Java program.



Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java