• Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
MYTAT
  • Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
Java
  • Java Introduction
  • Java Getting Started
  • Java Syntax
  • Java Comments
  • Java Variables
  • Java Data Types
  • Java Type Casting
  • Java Operators
  • Java Strings
  • Java Math
  • Java Booleans
  • Java If ... Else
  • Java Switch
  • Java While Loop
  • Java For Loop
  • Java Break And Continue
  • Java Arrays
  • Java Methods
  • Java Method Parameters
  • Java Method Overloading
  • Java Scope
  • Java Recursion
  • Java OOP
  • Java Classes And Objects
  • Java Class Attributes
  • Java Class Methods
  • Java Constructors
  • Java Modifiers
  • Java Encapsulation
  • Java Packages
  • Java Inheritance
  • Java Polymorphism
  • Java Inner Classes
  • Java Abstraction
  • Java Interface
  • Java Enums
  • Java User Input (Scanner)
  • Java Date And Time
  • Java ArrayList
  • Java LinkedList
  • Java HashMap
  • Java HashSet
  • Java Iterator
  • Java Wrapper Classes
  • Java Exceptions - Try...Catch
  • Java Regular Expressions
  • Java Threads
  • Java Lambda Expressions
  • Java Files
  • Java Create And Write To Files
  • Java Read Files
  • Java Delete Files
  • Home
  • Courses
  • Java
  • Java Getting Started

Java Getting Started

Previous Next

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)
 

If you do not have Java installed on your computer, you can download it for free at oracle.com.

Note: In this tutorial, we will write Java code in a text editor. However, it is possible to write Java in an Integrated Development Environment, such as IntelliJ IDEA, Netbeans or Eclipse, which are particularly useful when managing larger collections of Java files.



Practice Excercise Practice now

Setup For Windows

To install Java on Windows:

  1. Go to "System Properties" (Can be found on Control Panel > System and Security > System > Advanced System Settings)
  2. Click on the "Environment variables" button under the "Advanced" tab
  3. Then, select the "Path" variable in System variables and click on the "Edit" button
  4. Click on the "New" button and add the path where Java is installed, followed by \bin. By default, Java is installed in C:\Program Files\Java\jdk-11.0.1 (If nothing else was specified when you installed it). In that case, You will have to add a new path with: C:\Program Files\Java\jdk-11.0.1\bin
    Then, click "OK", and save the settings
  5. At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine



Practice Excercise Practice now

Java Quickstart

  1. Writing the Java Code:

    • You begin by creating a Java file named Main.java. In Java, every application starts with a class definition, and the class name must match the filename.
    • Inside Main.java, you define a class named Main with a main method. The main method is the entry point for Java applications and serves as the starting point for execution.
    • Within the main method, you use the System.out.println() method to print the "Hello World" message to the console.
  2. Compiling the Java Code:

    • After saving Main.java, you open the Command Prompt and navigate to the directory where the file is saved.
    • You use the javac command to compile the Java source code. In this case, you run javac Main.java. If there are no errors in the code, the compiler will generate a bytecode file named Main.class.
  3. Running the Java Program:

    • Once the code is successfully compiled, you use the java command to execute the program. You type java Main in the Command Prompt.
    • The Java Virtual Machine (JVM) loads the bytecode from Main.class and starts executing the main method.
    • As a result, the "Hello World" message is printed to the console, indicating that the program has run successfully.

Main.java

Try it now

 

public class Main { public static void main(String[] args) { System.out.println("Hello World"); } }


 

Don't worry if you don't understand the code above - we will discuss it in detail in later chapters. For now, focus on how to run the code above.

Save the code in Notepad as "Main.java". Open Command Prompt (cmd.exe), navigate to the directory where you saved your file, and type "javac Main.java":

C:\Users\Your Name>javac Main.java


 

This will compile your code. If there are no errors in the code, the command prompt will take you to the next line. Now, type "java Main" to run the file:
 

C:\Users\Your Name>java Main
 

The output should read:

Try it now

Hello World
 

Congratulations! You have written and executed your first Java program.


 



Practice Excercise Practice now

Previous Next
COMPANY
  • About us
  • Careers
  • Contact Us
  • In Press
  • People
  • Companies List
Products
  • Features
  • Coding Assessments
  • Psychometric Assessment
  • Aptitude Assessments
  • Tech/Functional Assessments
  • Video Assessment
  • Fluency Assessment
  • Campus
 
  • Learning
  • Campus Recruitment
  • Lateral Recruitment
  • Enterprise
  • Education
  • K 12
  • Government
OTHERS
  • Blog
  • Terms of Services
  • Privacy Policy
  • Refund Policy
  • Mart Category
Partner
  • Partner Login
  • Partner Signup

Copyright © RVR Innovations LLP 2025 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP