DEV Community

Cover image for Java Newbie to Pro? Day 1 – How I Set Up My Java Dev Environment
Nabil Mahmud
Nabil Mahmud

Posted on • Edited on

Java Newbie to Pro? Day 1 – How I Set Up My Java Dev Environment

In this post, I’ll walk you through how I set up my Java development environment on my primary (and only) machine—a Dell Latitude running Ubuntu.

Setting Up the Development Environment

1. Downloading and Extracting the JDK

First, I downloaded the latest stable JDK. To be more specific, I went with JDK 21's x64 Compressed Archive option.

After a little while, the JDK archive stuff got downloaded into my pc's Downloads directory. Following the download, I extracted the contents of the archive into the Home directory using the following command:

tar -xvf Downloads/jdk-21_linux-x64_bin.tar.gz -C ~
Enter fullscreen mode Exit fullscreen mode

By default, this created a new folder named jdk-21.0.6 (the directory name could be different for you as it depends on the version of the JDK you downloaded initially). To keep things neat and have a consistent directory name, I did the following:

  • Created a new directory named jdk-21:
mkdir ~/jdk-21
Enter fullscreen mode Exit fullscreen mode
  • Moved all the extracted contents into this new directory:
mv ~/jdk-21.0.6/* ~/jdk-21/
Enter fullscreen mode Exit fullscreen mode
  • Finally, I removed the now-empty jdk-21.0.6 folder:
rmdir ~/jdk-21.0.6
Enter fullscreen mode Exit fullscreen mode

At this point, I had my JDK neatly placed inside ~/jdk-21.

2. Setting Up the Environment Variables

To ensure that my system could recognize Java commands globally, I had to set up environment variables. Here’s how I did it:

  • Opened the bashrc file for editing using Nano:
nano ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
  • Scrolled to the bottom and added the following lines:
# Java
export JAVA_HOME="/home/nabil/jdk-21"
export PATH=$PATH:$JAVA_HOME/bin
Enter fullscreen mode Exit fullscreen mode

Image description

  • Saved the file (CTRL + X, then Y, then Enter). Applied the changes immediately by running:
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

To verify that Java was installed and accessible, I ran:

java --version
Enter fullscreen mode Exit fullscreen mode

Image description
It successfully displayed the installed Java version! 🎉

3. Installing Eclipse IDE

Since Caleb uses Eclipse IDE in his tutorial, I decided to install it for consistency. I installed Eclipse from Ubuntu's App Center.

4. Creating My First Java Project

With Eclipse up and running, I created a new Java project to test everything:

  • Clicked on File → New → Java Project.
  • Named the project hello.
  • Clicked Finish to create the project.
  • And that’s it! My Java development environment was fully set up and ready to go.

Image description

P.S. If you think my explanation sucks(it actually does😆), then you should be following this guide from dev.java which is really awesome, by the way!

Here's the link to day 2 of my Java Journey😉

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.