Getting started with Java!!

FullStackTips
2 min readJan 20, 2023

--

Java JDK components(image taken from softwaretestinghelp)

Java Development Kit (JDK) is a software development environment used for developing Java applications and applets.

Java Runtime Environment (JRE) is a part of the Java Development Kit (JDK), but can be downloaded separately. It is the component of the JDK responsible for running Java programs, it contains the Java Virtual Machine (JVM), the Java class libraries, and other supporting files.

To install JDK on Mac, you can download the JDK from the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html) and then follow these steps:

  1. Open the downloaded DMG file
  2. Double-click on the JDK package icon
  3. Follow the on-screen instructions to install JDK

To install JDK on Windows, you can download the JDK from the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html) and then follow these steps:

  1. Open the downloaded exe file
  2. Follow the on-screen instructions to install JDK

After the installation is done, the folder structure of Java on your machine will look like:

  • The JDK directory, which contains the bin, lib, and other directories
  • The JRE directory, which contains the bin, lib, and other directories
  • The bin directory contains the Java executables such as java and javac
  • The lib directory contains the class libraries and other support files

Next step is to add the java executable to your PATH environment variable. This can be done by set PATH environment variables.

To set the path and classpath on Mac OS, you can use the terminal and run the following commands:

  • To set the path: export PATH=$PATH:/path/to/jdk/bin
  • To set the classpath: export CLASSPATH=”path_to_your_class_files”

To set the path and classpath on Windows, you can use the command prompt and run the following commands:

  • To set the path: set PATH=%PATH%;C:\path\to\jdk\bin
  • To set the classpath: set CLASSPATH=”path_to_your_class_files”

A sample Java class to compile and run would look like:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

You can compile this class using the command: javac HelloWorld.java and run it using the command: java HelloWorld

There are several IDEs available for Java development like Eclipse (https://www.eclipse.org/downloads/), IntelliJ IDEA (https://www.jetbrains.com/idea/download/), NetBeans (https://netbeans.org/downloads/) and so on. These IDEs provide a visual development environment, which makes it easy to write, debug, and run Java code.

You need to be sure that the JDK and JRE are installed correctly and the path and classpath are set correctly before running any Java program.

Please follow my page for more content. Thanks for reading it!

https://medium.com/@fullstacktips/getting-started-with-java-f89f75c4a75?source=friends_link&sk=998ffdf383db2760254484f14a98feb8

--

--

FullStackTips

I am full stack developer with over 15 years of experience in various programming languages. https://medium.com/@fullstacktips/membership