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 ~
By default, this created a new folder named jdk-21.0.6 (or something similar, depending on the JDK version). To keep things neat and have a consistent directory name, I did the following:
- Created a new directory named jdk-21:
mkdir ~/jdk-21
- Moved all the extracted contents into this new directory:
mv ~/jdk-21.0.6/* ~/jdk-21/
- Finally, I removed the now-empty jdk-21.0.6 folder:
rmdir ~/jdk-21.0.6
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
- Scrolled to the bottom and added the following lines:
# Java
export JAVA_HOME="/home/nabil/jdk-21"
export PATH=$PATH:$JAVA_HOME/bin
- Saved the file (CTRL + X, then Y, then Enter). Applied the changes immediately by running:
source ~/.bashrc
To verify that Java was installed and accessible, I ran:
java --version
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.
Top comments (0)