Basic Java Tutorial for Beginners

Last updated on Apr 26,2024 7.4K Views

Basic Java Tutorial for Beginners

edureka.co

Java has become an important programming language in today’s world with its universal presence in our day-to-day life. Released by Sun Microsystems in 1995, this class-based object-oriented program is often related to the likes of C & C++ due to its similarity in coding.  Often termed as the programming language where you can ‘Write once, Run Anywhere’, Java Applications are compiled to Bytecode and run in Java Virtual Machine (JVM).

One of the typical questions that any programmer would ask for is how to get started? The tutorial gives you a step-by-step process from Downloading, Installing, Setting up the Environment and running a ‘Mystery’ Java Application.

Step 1: Downloading Java

The Java Application can be downloaded from the link Download where the current version (Version 7.0) is available.  You can also download the version as per your Operation system by clicking here.

Step 2: Setting up Environment Variables

Once the installation is complete, it is important to set up the Environment Variables. They are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the operating system in which a process runs.

After the downloading  of the Java file, we must run the .exe file to install Java in the machine. If your operating system is Windows then :

In case your operating system is based on Windows Vista/7, right click  on the “Computer” and select the option ‘Properties’. In the Property window select the “Advanced System Settings” and then select the “Advanced” tab and click “Environment Variables”. A window will appear were you can enter a new environment variable under User/System Variables by clicking on the New button.

Classpath: The Classpath are an important component of Setting up the Environment Variables and it points to the locatio of the JDK home directory. It also contains the address of the folder from where the jars get loaded by the ClassLoader.

Java_Home : This environment variable will point the location of Java home directory.

Step 3: Checking if Java is Installed

After setting the environment, we can go to the command prompt and type the following to check if Java is installed.

Start > Run > Type Cmd

Under the Command Prompt(Black Window), we type:

java version

If installed correctly, it will give you the output:

C:UsersJbt>java -version

java version “1.6.0_25”
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing

*as per the version downloaded

or in case it is not installed it will show:

‘java’ is not recognized as an internal or external command,

operable program or batch file.

Step 4 : Choosing a Java editor

To start writing and compiling programs, its important to choose a Java-editor(IDE) which is ‘An integrated development environment (IDEa software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger.’

Congrats! You are all set to work on Java. If you are interested in Java role, then you must check out these Java interview questions before going for the job interview.

Mystery Program: Guess the Output?

Here is a program that we would like to share with you with a specific output. Based on the logic of the program, fill the blank and compile to know output!

Hint : It’s about an Italian person!

class ___________
{
public static void main(String args[])
{		
int prev, next, sum, n;
prev=next=1
for(n=1;n<=10;n++)
{
System.out.println(prev);
sum=prev+next;
prev=next;
next=sum;
}
}
}

Build real-world apps from scratch and showcase your skills with our hands-on Flutter APP Development Course.

Got a question for us? Mention them in the comments section and we will get back to you. 

Upcoming Batches For Java Certification Training Course
Course NameDateDetails
Java Certification Training Course

Class Starts on 4th May,2024

4th May

SAT&SUN (Weekend Batch)
View Details
Java Certification Training Course

Class Starts on 25th May,2024

25th May

SAT&SUN (Weekend Batch)
View Details
BROWSE COURSES
REGISTER FOR FREE WEBINAR UiPath Selectors Tutorial