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 :
- 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:WINDOWSSYSTEM32;c:Program Filesjavajdkin
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
*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,
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. 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.