8. Downloading Java and Maven in Ubuntu Desktop

Before diving into the installation process, it's important to understand why Java and Maven are crucial components in software development:
Java Development Kit (JDK)
The JDK is a software development environment used for developing Java applications. It includes:
The Java Runtime Environment (JRE) - needed to run Java applications
Development tools like the Java compiler (javac), debugger, and other utilities
Java libraries and API documentation essential for Java development
Apache Maven
Maven is a powerful project management tool that provides:
Dependency management - automatically downloading and managing external libraries
Standardized project structure - enforcing conventions for organizing code
Build lifecycle management - handling compilation, testing, packaging, and deployment
Plugin architecture - extending functionality through various plugins
Why Install Both?
Java and Maven work together in a typical development workflow:
Java (JDK) provides the core programming environment
Maven simplifies building and managing Java projects
Together they create a standardized, efficient development environment
Setting up these tools properly with environment variables like JAVA_HOME and MAVEN_HOME ensures that your development tools and build scripts can locate these resources consistently across your system.
1. Downloading and Installing OpenJDK:
**Update Package Lists:**Bash
sudo apt update
**Install OpenJDK (e.g., OpenJDK 11):**Bash
sudo apt install openjdk-11-jdk
**Verify Installation:**Bash
java -version javac -version
Set JAVA_HOME (Optional but Recommended):
Find the JDK installation path: Bash Note the path (e.g.,
/usr/lib/jvm/java-11-openjdk-amd64
).sudo update-alternatives --config java
Add
JAVA_HOME
to your.bashrc
or.zshrc
file: Bashecho 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' >> ~/.bashrc echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc source ~/.bashrc
2. Downloading and Installing Maven:
Download Maven:
Go to the Apache Maven downloads page: https://maven.apache.org/download.cgi
Download the binary
tar.gz
archive (e.g.,apache-maven-3.9.6-bin.tar.gz
).Place the archive in a suitable directory (e.g.,
/opt
).
**Extract Maven:**Bash
sudo tar -xzf apache-maven-3.9.6-bin.tar.gz -C /opt
**Create a Symbolic Link (Optional but Recommended):**Bash
sudo ln -s /opt/apache-maven-3.9.6 /opt/maven
Set MAVEN_HOME and Add to PATH:
Add these lines to your
.bashrc
or.zshrc
file: Bashecho 'export MAVEN_HOME=/opt/maven' >> ~/.bashrc echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> ~/.bashrc source ~/.bashrc
**Verify Installation:**Bash
mvn -version
Important Notes:
Replace version numbers with the versions you want to install.
The paths provided are examples. Adjust them to match your system.
If you are using a container, you will need to perform these steps inside of the dockerfile.
By following these steps, you can configure Jenkins Global Tool Configuration (for traditional agents) and install JDK and Maven on your Ubuntu machine.
Subscribe to my newsletter
Read articles from Adarsh Bhaskar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Adarsh Bhaskar
Adarsh Bhaskar
Hi there! I’m Adarsh, a passionate information science student with hands-on experience in machine learning, software development, and data analysis. I thrive on solving complex problems and enjoy collaborating with teams to bring innovative solutions to life. Whether it’s developing a recommendation engine or streamlining workflows with automation, I love diving into new technologies. I’m always eager to learn and explore fresh ideas, especially in the world of Flutter app development!