Environment Setup for Java
To play with Java, first you need to set an environment in which we can code, compile, and run the Java program. So, we need to install the environment setup on the system. Java environment setup is freely available on the web or just download it from the given link which is the latest version of Java i.e. Java SE (version 8.0) and the most popular one.
Now after downloading the setup, we need to install it by running the file .exe (for windows OS) and follow the instructions. Once Java setup installed on the system, we would also need to set the environment variables (path) to point to correct installation directories. The path is required to be set up for using tools, Javac, Java, etc.
If our Java source file is already inside the jdk/bin directory, path is not required to be set, because all the tools will be available in the current directory.
But, if our file is outside the jdk/bin directory, then there is necessity to set the path.
Here, we will learn to set the path in windows as well as for other operating systems. First of all, we will discuss to set the path in windows.
There can be two ways of setting path in windows i.e. temporary and permanent way.
When we set the path by using command prompt, then it set the path temporarily. To set the path by command prompt, we need to just follow the instruction given below.
- Open the command prompt by pressing windows start button and typing CMD and then pressing enter.
- Now, copy the path of jdk/bin directory, path will be like this – c:\Program Files\java\jdk\bin
- Now, in command prompt, type set path = copied_path and press enter.
By doing this, jdk path will be set, but temporarily.
For setting path permanently, again we need to follow the instructions given below.
- Right click on my computer and select the properties
- Now click on advanced setting available at left panel.
- Now, in advanced tab, click on Environment variables
- Now click on New… tab in user variables.
- Now, type path in variable name
- Now copy the path of jdk.
- Now, paste the copied path in the variable value
- Now, click ok and then ok and again ok and you are done.
Setting path in Linux, UNIX, Solaris
Setting the path in Linux OS is similar as setting the path in the Windows OS. But here we use export tool rather than set. We can set the path in Linux OS like this:
By this, JDK will be installed in the home directory under Root (/home).
Few popular Java Editors
Now after setting path and getting ready to code, we would also need a text editor to write our Java programs. There are even more sophisticated IDEs available in the market. But for now, you can consider one of the following:
- Notepad or Notepad++
On Windows machine we can use any simple text editor like Notepad, Textpad.
It is a Java IDE that is open-source and free which can be downloaded from the following link Netbeans.
It is also a Java IDE developed by the eclipse open-source community and can be downloaded from this link Eclipse.
Now we are done with everything and became ready to move further to understand the internal stuffs related to Java program such as JVM, JRE, Runtime, Compile time, syntax, etc. which will be discussed in next part of this series.
Keep visiting here for more tut like this 🙂
Thank you for your patience 🙂
First & Basic Program of Java
To develop or create your first Java Program, you need to fulfil the basic needs of having all the accessories to write the program and more…