Basic Java Tutorial for Beginners

Recommended by 17 users

Oct 9, 2014
Basic Java Tutorial for Beginners
Add to Bookmark Email this Post 2.6K    0

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 with Java? The ‘Basic Java 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 Java is installed 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 :

  • Right-click on My Computer and click on properties
  • Click on the Environment Variables’ under the Advanced tab
  • Then alter the path variable to ‘C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin

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

  • For a simple start, you could work on Notepad or Textpad that will be pre-installed in your system.
  • Notepad: On Windows machine you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.
  • Netbeans: A popular open-source IDE that is free and can be downloaded here.
  • Eclipse: is also a Java IDE developed by the eclipse open-source community and can be downloaded from here .

Congrats! You are all set to work on Java.

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;

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

Related Posts:

Unveil the Magic of Java Course with Edureka!

Hadoop for Java Professionals

Learn Java/J2EE & SOA

Share on

24 X 7 Customer Support X

  • us flag 1-800-275-9730 (Toll Free)
  • india flag +91 88808 62004