Summary
Apache Maven is a popular open source software to build and manage projects of Java (and also other programming languages), licensed under Apache-2.0.
With Devuan 5 Daedalus based on Debian 12 bookworm, it is easy to use it thanks to their packages management. However, it is not always the latest. Actually, Maven Debian 12 offers is currently 3.8 instead of 3.9. Well, is it a big problem ? Probably, no.
In my previous post, I installed OpenJDK 21, the latest, manually on Devuan 5. Here, I will show how to install Maven manually, too.
Of course, it is easier to run apt install maven
🫣
Environment
- OS: Devuan 5 Daedalus
- based on Debian 12
- App Engine: OpenJDK 21
- Project Build and Management: Apache Maven 3.9.5
Tutorial
Suppose that your PATH
includes Java 21 bin
which appears before those of other Java versions such as 17 (the previous LTS).
Get Apache Maven package
Visit: https://maven.apache.org/download.cgi
Get the binary with the command line, for example:
$ curl -LO https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz
You can verify the download by comparing the checksums between the server and the local. Use the command lines below, for example:
$ echo "$(curl -s https://downloads.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz.sha512) apache-maven-3.9.5-bin.tar.gz" | \
sha512sum -c
apache-maven-3.9.5-bin.tar.gz: OK
It means it was confirmed that the server checksum was equal to the local one:
$ # checksum of the downloaded file
$ sha512sum apache-maven-3.9.5-bin.tar.gz
4810523ba025104106567d8a15a8aa19db35068c8c8be19e30b219a1d7e83bcab96124bf86dc424b1cd3c5edba25d69ec0b31751c136f88975d15406cab3842b apache-maven-3.9.5-bin.tar.gz
Place files
Extract it:
$ tar xzf apache-maven-3.9.5-bin.tar.gz
The result is as below:
$ ls {.,apache-maven-3.9.5}
.:
apache-maven-3.9.5/ apache-maven-3.9.5-bin.tar.gz
(...)
apache-maven-3.9.5:
bin/ boot/ conf/ lib/ LICENSE NOTICE README.txt
Now you have apache-maven-3.9.5
directory which contains bin
etc. 👍
Set environment variables
Update PATH
to include Maven bin
:
$ # case bash
$ export PATH=$(readlink -f ./apache-maven-3.9.5/bin):$PATH
$ # case fish
$ #set -x PATH $(readlink -f ./apache-maven-3.9.5/bin/):$PATH
Conclusion
Now Apache Maven is in your hands:
$ mvn --version
Maven home: /(...)/apache-maven-3.9.5
Java version: 21, vendor: Oracle Corporation, runtime: /(...)/jdk-21
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.1.0-13-amd64", arch: "amd64", family: "unix"
Let's create an example project named "maven-example-01" and run it:
$ # create a project
$ mvn archetype:generate \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false \
-DgroupId=com.myexample.app \
-DartifactId=maven-example-01
$ # files are generated
$ cat src/main/java/com/myexample/app/App.java
package com.myexample.app;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
$ # build it
$ mvn package
$ # run
$ java -cp \
target/maven-example-01-1.0-SNAPSHOT.jar \
com.myexample.app.App
Hello World!
Yay 🙌
Top comments (0)