Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction:
2.
Different Platforms: 
3.
Installation for different OS:
4.
Popular Java Editors:
5.
FAQs:
6.
Key Takeaways:
Last Updated: Mar 27, 2024

Setting up the environment

Create a resume that lands you SDE interviews at MAANG
Speaker
Anubhav Sinha
SDE-2 @
12 Jun, 2024 @ 01:30 PM

Introduction:

Java is a general-purpose language that is concurrent, class-based, object-oriented. It typically complied with bytecode that can run on any Java Virtual Machine irrespective of the computer architecture. In Java, JVM, JRE, and JDK are three platform-dependent because the configuration of each Operating System is Different.

Also see, Duck Number in Java and Hashcode Method in Java.

Different Platforms: 

  • JDK(Java Development Kit): JDK is dedicated to particularly software developers which includes development tools such as the Java Compiler, Javadoc, Jar, and a debugger.
  • JRE(Java Runtime Environment): It contains different parts of Java libraries required to run Java programs intended for the user’s purpose.
  • JVM(Java Virtual Machine): It’s an abstract machine that provides a runtime environment in which java bytecode can be executed. They are available for many hardware and software applications.

Read more, how to run java program

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Installation for different OS:

  1. Windows:
  • Download Java8 JDK depending on the compatibility of the machine; it's different for Windows(32bit) and Windows(64bit).
  • After downloading the file, run the .exe file and follow the instructions to install Java on your computer. After installation, you need to set up the environment.
  • Go to Control Panel -> System and Security -> System. Under the Advances System Setting option click on Environment Variables as highlighted below.
  • Now, you have to alter the “Path” variable under System. 
  • You need to choose the path where you have installed Java “C:/Program Files/Java/jdk/bin” or “C:/Program Files(x86)/Java/jdk/bin”.
  • Click on OK, Save the setting, and you are ready to go. Now check whether the installation done is successful or not. Open the cmd and type javac -version. You will notice that java is running on your machine.

2. Linux Operating System:

  • In Linux, there are numerous ways to install Java. But we will prefer the easy way to install java using a terminal. 
  • Open the terminal, then type the following command.
    Sudo-apt get install OpenJDK-8-the command is shown below for
  • The command below for the “JAVA_HOME”(Environment Variable).
    Export JAVA_HOME = /usr/lib/jvm/java-8-openjdk
  • Type the command shown below for “PATH”(Environment Variable).
    Export PATH = $PATH:/usr/lib/jvm/java=8-openjdk/bin
  • We are done setting the environment.


3. macOS Operating System.

  • Open the terminal from the application folder.
  • Now enter the following command.
    java –version
    javac –version
  • Once we are done installing JDK now, we need to set up the java home environment variable.
  • Enter the command ls -al.
  • Enter the command to check the proper installation of java in macOS
    echo $JAVA_HOME
  • After this, go to the root folder in the terminal and write the command ‘touch./bash_profile’. You can see the bash profile is created.
  • Edit the .bash_profile created for java; you need to enter the command marked below.
    Export JAVA_HOME = $(/usr/libexec/java_home)
  • Verify this command by typing the command
    source.bash_profile
    echo $JAVA_HOME

You can also read about the topic of Java Destructor. and Swap Function in Java

Popular Java Editors:

Notepad: In windows, you can simply use a text editor like Notepad, TextPad.

Netbeans: A Java IDE is an available source and free to download.

Eclipse: A Java IDE developed by the eclipse open-source community can be downloaded easily.

You can also check about Java Tokens here.

FAQs:

Q: Why do we need to set environment variables in JAVA?

A: Environment variables are set to permit access to command-line tools and empower different devices to connect with SDKs more easily. For instance, with Java on Windows, on the off chance that the environment variable is not set on the PATH, running javac is significantly more cumbersome because you want to type in the full path to the command each time:

 

Q: How to set environment variables in Java to run an application?

A: To run the Java application, install a Java Development Kit (JDK). Furthermore, there are two environment variables to set. One is a path, and the other is a classpath variable. First of all, download the latest JDK from its authority website of Oracle.

 

Key Takeaways:

In this blog we covered the following points:

  • What are the different platforms in Java?
  • How to install java on different  Operating Systems like Windows, Linux, and macOS.
  • What are the current popular Java Editors?

If you want to know more about the installation of Java on different operating systems.

Go to this Java download.

Check out this problem - Root To Leaf Path

Related article: 

Java Tokens

Difference between JDK, JRE and JVM 

Why is Java Platform Independent

Java Verify

Eclipse ide for Java Developers

Addition of two numbers in java

Previous article
Predicate in Java 8
Next article
New Keyword in Java
Live masterclass