💻Step 1: Installation and Configuration of Java- 1st Hour

Learn with our youtube video –

 

Quick steps for all three operating systems-

Operating SystemInstallation Process
Windows1- Go to the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html) and click on the “Download” button for the JDK.
2- Accept the Oracle Binary Code License Agreement and click on the link to download the JDK installation file for Windows.
3- Save the downloaded file to a location on your computer, such as the desktop.
4- Double-click the downloaded installation file to launch the JDK installation wizard.
5- Click “Next” to begin the installation process.
6- On the “Custom Setup” page, you can choose the installation location and any additional components to install. The default options are usually sufficient for most users. Click “Next” to continue.
7- On the “Ready to Install” page, review the installation options and click “Install” to begin the installation process.
8- The installation process will take a few minutes to complete. When it’s done, the “Completing the JDK Setup Wizard” page will be displayed.
9- Click “Close” to exit the wizard and complete the installation.

After installing the JDK, you may need to add it to your system path so that you can use it from the command line. To do this on Windows, you can follow these steps:
Open the Start menu and search for “Environment Variables”.

10- Click on “Edit the system environment variables” to open the System Properties window.
11- Click on the “Environment Variables” button.
Under the “System Variables” section, scroll down and find the “Path” variable.
12- Click on the “Edit” button to edit the variable.
13- In the “Edit Environment Variable” window, click on the “New” button and add the path to the JDK installation, such as “C:\Program Files\Java\jdk1.8.0_241\bin”.
14- Click “OK” to save the changes and close the window.
Linux1. Download the JDK tar file from the Oracle website(https://www.oracle.com/java/technologies/javase-downloads.html).
2. Extract the tar file to the directory where you want to install the JDK.
3. Open a terminal and navigate to the bin directory within the JDK installation directory.
4. Run the command sudo alternatives --install /usr/bin/java java /path/to/jdk1.8.0/bin/java 20000 to set the default JDK.
5. Run the command sudo alternatives --install /usr/bin/jar jar /path/to/jdk1.8.0/bin/jar 20000 to set the default jar command.
6. Run the command sudo alternatives --install /usr/bin/javac javac /path/to/jdk1.8.0/bin/javac 20000 to set the default javac command.
7. Run the command sudo alternatives --set jar /path/to/jdk1.8.0/bin/jar to set the default jar command.
8. Run the command sudo alternatives --set javac /path/to/jdk1.8.0/bin/javac to set the default javac command.
9. Set the JAVA_HOME environment variable by adding the following line to your ~/.bashrc file: export JAVA_HOME=/path/to/jdk1.8.0
10. Run the command source ~/.bashrc to apply the changes to your current terminal session.
macOS1- Go to the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html) and click on the “Download” button for the JDK.
2- Accept the Oracle Binary Code License Agreement and click on the link to download the JDK installation file for macOS.
3- Save the downloaded file to a location on your computer, such as the desktop.
4- Double-click the downloaded installation file to launch the JDK installer.
5- Click “Continue” to begin the installation process.
6- On the “Introduction” page, click “Continue” to proceed.
7- On the “License” page, review the license agreement and click “Agree” to continue.
8- On the “Installation Type” page, you can choose the installation location and any additional components to install. The default options are usually sufficient for most users. Click “Install” to begin the installation process.
9- Enter your password to allow the installer to make changes to your system.
10- The installation process will take a few minutes to complete. When it’s done, the “Install JDK” page will be displayed.
11- Click “Close” to exit the installer and complete the installation.

On macOS, you can set the JAVA_HOME environment variable by adding the following line to your ~/.bash_profile file:

12- export JAVA

Detailed steps for all three operating systems-

💻 Windows User 💡

1-Installation of java (java development kit)💡

  💡  Step 1:- Download the latest Java development kit (JDK) from oracle home site                      💡  A->Oracle Homepage (Click here)
  💡  B->Download the “Windows xxx Installer”

Installer

💡 Step 2: Set the path (of tools) –
     💡 A- Path is required for using tools i.e., javac, java etc.,
     💡 B- For setting path permanently, perform these steps->
     💡 C- * Go to My computer/This PC ‘properties’ -> ‘advanced system settings’ ->                                    ‘Environment Variables ‘-> ‘New’: it should be like following:

“Variable name: path

“Variable Value: (path of bin folder of JDK) i.e. C:\Program Files\Java\jdkX.X._XX\bin

2

Congratulations! 💡

You are done !! Now to check whether installation is done correctly, type java -version in the Terminal.
You will see that java is running on your machine.

💻 Linux User

Step 1- Go to Application -> Accessories -> Terminal.

sudo apt-get install openjdk-8-jdk

Or

 💡  Step 1:- Download the latest Java development kit (JDK) from oracle home site                               💡  A->http://www.oracle.com/technetwork/java/javase/downloads/index.html
         💡  B-> Switch tab to Linux

Note-change 8 in above line with current java version.

Step 2-
  💡 A- Open terminal ->

export JAVA_HOME = /usr/lib/jvm/java-8-openjdk

(Note: the default path is as shown, but if you have install OpenJDK at other location then set that path.)

Step 3-
💡 A- Open terminal ->

export PATH = $PATH:/usr/lib/jvm/java-8-openjdk/bin

(Note: the default path is as shown, but if you have install OpenJDK at other location then set that path.)

Congratulations! 💡

You are done !! Now to check whether installation is done correctly, type java -version in the Terminal.
You will see that java is running on your machine.

💻Mac Users –   How to Install JDK on macOS

💡Step 1: Download JDK

  1. Goto JDK (or Java SE) download site @ https://www.oracle.com/java/technologies/javase-downloads.html.
  2. Under “Oracle JDK”, click “JDK Download”.
  3. Download the “macOS DMG installer” (e.g, jdk-15.0.{x}_osx-x64_bin.dmg – about 172MB, where {x} is a fast changing update number).

💡Step 2: Install JDK/JRE

  1. Double-click the downloaded Disk Image (DMG) file. Follow the screen instructions to install JDK/JRE.
  2. Eject the DMG file.
  3. To verify your installation, open a “Terminal” and issue these commands.

// Display the JDK version

javac -version javac 15.0.{x}

// Display the JRE version

java -version java version “15.0.{x}” .

// Display the location of Java Compiler which javac /usr/bin/javac

// Display the location of Java Runtime which java /usr/bin/java

2-Installation of IDE

There are many ide for development, but here are top in list, install any one-

(1)- Intelij
(2)- Eclipse
(3)- Netbeans

installation process for Eclipse, NetBeans, and IntelliJ IDEA on Windows, Linux, and Mac:

IDEWindowsLinuxMac
Eclipse (Recommended/Free)1. Download the Eclipse installer from the Eclipse website.1. Download the Eclipse installer from the Eclipse website.1. Download the Eclipse installer from the Eclipse website.
2. Run the installer and follow the prompts to install Eclipse.2. Extract the downloaded file and run the Eclipse executable.2. Double-click the downloaded Eclipse installer and follow the prompts to install Eclipse.
NetBeans (Outdated/free)1. Download the NetBeans installer from the NetBeans website.1. Download the NetBeans installer from the NetBeans website.1. Download the NetBeans installer from the NetBeans website.
2. Run the installer and follow the prompts to install NetBeans.2. Extract the downloaded file and run the NetBeans executable.2. Double-click the downloaded NetBeans installer and follow the prompts to install NetBeans.
IntelliJ IDEA (Paid/Trials, Professional use)1. Download the IntelliJ IDEA installer from the JetBrains website.1. Download the IntelliJ IDEA installer from the JetBrains website.1. Download the IntelliJ IDEA installer from the JetBrains website.
2. Run the installer and follow the prompts to install IntelliJ IDEA.2. Extract the downloaded file and run the IntelliJ IDEA executable.2. Double-click the downloaded IntelliJ IDEA installer and follow the prompts to install IntelliJ IDEA.

Note that the installation process may vary depending on the specific version of the software and the operating system you are using. It is always a good idea to refer to the official documentation for the most up-to-date and accurate instructions.

3- FIRST java program –

Some common rules to follow-

1- Filename should be same as Class name (i.e FirstProg.java)

2- Class name must be start with Uppercase letter (i.e FirstProg (same as filename))

public class FirstProg {
    public static void main(String[] args){
        System.out.println("Yes It's working fine here");
    }
}

public class FirstProg {

‘public’ Java modifier (Step – 8)

‘class’ is keyword (Step – 4)

‘FirstProg’ is user defined custom class name

‘{‘ is open curly bracket for group of code lines

public static void main(String[] args){

‘public’ Java modifier (Step – 8),

‘static’ Java modifier (Step – 8),

‘void’ is keyword which is used when we don’t return anything (String,int etc)

‘main’ is method name (JVM searches for method whose name is ‘main’ and executes it)

( ) after method name shows parameters

(String[] args) – we are passing String[] args as parameter to ‘main’ method,

String – It’s a class which is used as non primitive datatype in java, it’s used to support text data. (String a = ‘any text’)

String[] – [] is symbol used to show array, so String[] is array of Strings
i.e String[] b = [‘any text’, ‘some more’, ‘and more’]

args – It’s just a name declaration for String[] (just like ‘b’ in above example)-(you can use any name instead of args if you want to change)

System.out.println(“Yes It’s working fine here”);

System – System is class in java.lang package(folder)

out – It’s a object of PrintStream class inside System class

println – It’s a method declared in PrintStream class

System.out.println is way to print any text in console in java.

Interview Questions —

  • What java component(JVM/JRE/JDK) to install for java development?
  • Why to set path of bin folder in environment variables?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.