Ubuntu 22.04 安装 Apache Commons Geometry 指南

在 Ubuntu 22.04 上从零搭建 Apache Commons Geometry 1.0 环境,覆盖 JDK 17 与 Maven 准备、在线依赖引入、二进制包离线安装与源码编译三套方案,附真实回显与排查。

Apache Commons GeometryApache Commons Geometry2026/10/14

Ubuntu 22.04 安装 Apache Commons Geometry 指南

目标:在 Ubuntu 22.04 上从零搭建 Apache Commons Geometry 1.0 的使用环境,完成 JDK 17 + Maven 环境准备、三种依赖获取方式与真实几何运算验证。以下全部命令与回显均已在 Ubuntu 22.04(x86_64)实测通过。

一、环境信息

本节先固定本次实测所用软硬件基线,便于读者逐项对照复现。

  • 操作系统:Ubuntu 22.04.5 LTS(x86_64)
  • JDK:OpenJDK 17.0.20.1(java -version 实测)
  • 构建工具:Apache Maven 3.6.3(系统包仓库默认版本)
  • 目标库:Apache Commons Geometry 1.0(groupId org.apache.commons)
  • 依赖来源:https://downloads.apache.org/commons/geometry/、https://repo1.maven.org/maven2/(网络直连可达)
  • Maven 示例工程目录:/opt/geo-demo
  • 官方二进制包解压目录:/opt/commons-geometry/1.0
  • 手动 jar 存放目录:/opt/geo-jars

先确认系统版本与架构:

cat /etc/os-release | head -3
uname -m

输出:

PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
x86_64

二、前置条件

在开始安装前,请确认以下条件满足,否则后续步骤会因权限或网络问题中断。本节说明每项前置条件的作用与验证方法。

  1. root 权限或 sudo:安装 JDK、Maven 需要写入系统目录(/usr/lib/jvm、/usr/share/maven)。
  2. 网络可达:需要访问 downloads.apache.org(官方二进制/源码包)与 repo1.maven.org(Maven 中央仓库)。
  3. 磁盘空间:官方二进制包约 8 MB,加上本地 Maven 仓库缓存建议预留 ≥ 200 MB。
  4. 架构一致:本文面向 x86_64;Apache Commons Geometry 为纯 Java 库,无本地原生依赖,跨架构可用。

验证网络连通性(该库的下载目录与 Maven 中央仓库各探测一次):

curl -sI https://downloads.apache.org/commons/geometry/ | head -1
curl -sI https://repo1.maven.org/maven2/org/apache/commons/commons-geometry-core/ | head -1

输出:

HTTP/1.1 200 OK
HTTP/1.1 200 OK

⚠️ 注意:若内网无法直连上述域名,需按企业代理配置放行,否则 Maven 依赖与官方包均无法获取。本文实测环境为直连。

三、版本选型说明

Apache Commons Geometry 是 Apache 基金会的几何计算工具库。安装前先确认应选用的版本与模块,避免引入错误坐标。本节给出官方发行目录的实测版本清单与模块构成。

查询 downloads.apache.org 上的发行目录:

curl -s https://downloads.apache.org/commons/geometry/binaries/ | grep -oE 'commons-geometry-[0-9a-z.-]+-bin\.tar\.gz' | sort -u

输出:

commons-geometry-1.0-bin.tar.gz

说明:downloads.apache.org 只保留当前最新发行版,本次实测为 1.0;历史版本需到 archive.apache.org/dist/commons/geometry/binaries/ 获取,实测归档目录含两个版本:

curl -s https://archive.apache.org/dist/commons/geometry/binaries/ | grep -oE 'commons-geometry-[0-9a-z.-]+-bin\.tar\.gz' | sort -u

输出:

commons-geometry-1.0-beta1-bin.tar.gz
commons-geometry-1.0-bin.tar.gz

版本对照与选型:

版本状态发布日期线建议
1.0正式发行(release)首个正式版生产环境首选
1.0-beta1测试版(beta)早于 1.0仅用于验证历史行为

💡 技术拓展:几何计算库不止本文所用的 Apache Commons Geometry。常见选项对比——

库语言/形态特点适用场景
Commons GeometryJava 纯库Apache 出品、坐标/向量/直线/区域 BSP 类型丰富、无 JTS 依赖Java 服务内轻量几何运算
JTS Topology SuiteJava 纯库二维拓扑、空间关系与几何谓词最完备GIS 拓扑、空间分析
GeoToolsJava 库基于 JTS 的 GIS 工具集、坐标参考系统丰富地图数据与投影处理
ShapelyPython 库基于 GEOS,交互式脚本友好数据分析/脚本化几何处理

本文属于 Java 服务内几何计算场景,选用 Apache Commons Geometry:它不依赖 JTS、模块清晰、2D/3D 一体,且可通过 Maven 直接引入。

查询 Maven 中央仓库的实际可用版本:

curl -s https://repo1.maven.org/maven2/org/apache/commons/commons-geometry-euclidean/maven-metadata.xml

输出:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-geometry-euclidean</artifactId>
  <versioning>
    <latest>1.0</latest>
    <release>1.0</release>
    <versions>
      <version>1.0-beta1</version>
      <version>1.0</version>
    </versions>
    <lastUpdated>20210821014444</lastUpdated>
  </versioning>
</metadata>

1.0 正式发行版包含的模块(实测各 artifact 的 <release> 版本)如下:

Maven artifact(groupId 均为 org.apache.commons)release作用
commons-geometry-core1.0核心抽象:点/向量/超平面/BSP 区域
commons-geometry-euclidean1.0欧几里得 1D/2D/3D 几何类型
commons-geometry-spherical1.0球面几何
commons-geometry-io-core1.0几何 IO 抽象
commons-geometry-io-euclidean1.0欧几里得几何 IO(文本格式)

注意:commons-geometry-enclosing、commons-geometry-hull、commons-geometry-examples-* 在 Maven 上仅有 1.0-beta1,未随 1.0 正式发行,选用时勿误引。

日常开发绝大多数场景只需引入 commons-geometry-euclidean(它会传递引入 commons-geometry-core)。实测其完整传递依赖:

mvn -B dependency:tree

输出节选(实测首尾):

[INFO] demo:geometry-demo:jar:1.0.0
[INFO] \- org.apache.commons:commons-geometry-euclidean:jar:1.0:compile
[INFO]    +- org.apache.commons:commons-geometry-core:jar:1.0:compile
[INFO]    +- org.apache.commons:commons-numbers-core:jar:1.0:compile
[INFO]    +- org.apache.commons:commons-numbers-arrays:jar:1.0:compile
[INFO]    +- org.apache.commons:commons-numbers-angle:jar:1.0:compile
[INFO]    \- org.apache.commons:commons-numbers-quaternion:jar:1.0:compile
[INFO] BUILD SUCCESS

解读:commons-geometry-euclidean 依赖 commons-geometry-core 与 commons-numbers-*(core/arrays/angle/quaternion),版本均为 1.0。使用 Maven 时会自动解析,手动 jar 方式(方案 B)需自行补齐这 5 个依赖 jar。

四、在线安装方案(A:Maven 依赖引入)

官方推荐方式:通过 Maven 引入依赖,由构建工具自动解析传递依赖。适合可联网的开发/构建环境。

4.1 方案说明与适用场景

本方案在系统安装 JDK 与 Maven,再用一个最小 Maven 工程引入 commons-geometry-euclidean:1.0,最后编译运行验证。适合持续集成、可访问中央仓库的场景。

4.2 安装 JDK 17 与 Maven

先安装 JDK 17(Commons Geometry 要求 Java 8+,本文使用 17 LTS):

apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-17-jdk maven

输出节选(实测首尾):

Reading package lists...
Building dependency tree...
Reading state information...
...
Setting up openjdk-17-jdk (17.0.20.1+1-1~22.04) ...
...
Processing triggers for libc-bin ...

⚠️ 注意:若已安装过,apt-get install 会提示 openjdk-17-jdk is already the newest version (17.0.20.1+1-1~22.04).,属正常。

验证 JDK 与 Maven 生效:

java -version
mvn -version

输出:

openjdk version "17.0.20.1" 2026-08-18
OpenJDK Runtime Environment (build 17.0.20.1+1-1-22.04-Ubuntu)
OpenJDK 64-Bit Server VM (build 17.0.20.1+1-1-22.04-Ubuntu, mixed mode, sharing)
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 17.0.20.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "6.8.0-138-generic", arch: "amd64", family: "unix"

关键点:Java version 显示 17.0.20.1,说明系统自带 Maven 已正确使用 JDK 17,无需额外设置 JAVA_HOME。

4.3 创建 Maven 工程并引入依赖

创建工程目录并写入 pom.xml:

mkdir -p /opt/geo-demo/src/main/java

/opt/geo-demo/pom.xml 内容:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>demo</groupId>
    <artifactId>geometry-demo</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-geometry-euclidean</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
</project>

逐项说明:maven.compiler.source/target 指定 17;project.build.sourceEncoding 设为 UTF-8(源码含中文注释时必须,否则 javac 报 unmappable character);dependencies 仅声明 commons-geometry-euclidean:1.0,其余依赖由 Maven 传递解析。

4.4 编写最小验证程序

/opt/geo-demo/src/main/java/GeometryCheck.java 内容:

import org.apache.commons.geometry.euclidean.twod.Line;
import org.apache.commons.geometry.euclidean.twod.Lines;
import org.apache.commons.geometry.euclidean.twod.Vector2D;
import org.apache.commons.numbers.core.Precision;

public class GeometryCheck {
    public static void main(String[] args) {
        Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-10);
        Vector2D a = Vector2D.of(0.0, 0.0);
        Vector2D b = Vector2D.of(3.0, 4.0);
        Line xAxis = Lines.fromPoints(a, Vector2D.of(4.0, 0.0), precision);
        System.out.println("distance(a,b)        = " + a.distance(b));
        System.out.println("project (2,3) -> x   = " + xAxis.project(Vector2D.of(2.0, 3.0)));
        System.out.println("distance (2,3) -> x  = " + xAxis.distance(Vector2D.of(2.0, 3.0)));
    }
}

说明:用 Lines.fromPoints 构造 x 轴直线,分别计算两点距离、点的投影与点到直线的距离。

4.5 编译与运行验证

编译:

cd /opt/geo-demo
mvn -B compile

输出节选(实测首尾):

[INFO] -------------------------< demo:geometry-demo >-------------------------
[INFO] Building geometry-demo 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ geometry-demo ---
[INFO] Compiling 1 source file to /opt/geo-demo/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] Total time:  1.323 s

运行(由 Maven 解析出依赖 classpath):

mvn -q -B dependency:build-classpath -Dmdep.outputFile=cp.txt
java -cp "target/classes:$(cat cp.txt)" GeometryCheck

输出:

distance(a,b)        = 5.0
project (2,3) -> x   = (2.0, 0.0)
distance (2,3) -> x  = 3.0

验证点:distance(a,b) 为 5.0(3-4-5 直角三角形斜边),点 (2,3) 到 x 轴的投影为 (2.0, 0.0),垂距为 3.0。三者与几何常识一致,说明依赖已正确引入且可运行。

五、离线安装方案(B:官方二进制包)

适合内网隔离、无法访问中央仓库的环境。使用官方 bin 发行包 + 手动补齐第三方依赖 jar。

5.1 方案说明与适用场景

官方 commons-geometry-1.0-bin.tar.gz 内含 5 个模块 jar 及源码/javadoc,但不含 commons-numbers-* 依赖。因此本方案需:下载官方包 → 校验 → 解压 → 额外下载 5 个依赖 jar → javac/java 直跑验证。

5.2 下载与校验

下载官方二进制包及其 SHA512 校验文件:

cd /opt
curl -sO https://downloads.apache.org/commons/geometry/binaries/commons-geometry-1.0-bin.tar.gz
curl -sO https://downloads.apache.org/commons/geometry/binaries/commons-geometry-1.0-bin.tar.gz.sha512

校验(对比官方值与本机计算值):

cat commons-geometry-1.0-bin.tar.gz.sha512
sha512sum commons-geometry-1.0-bin.tar.gz

输出:

b170b25f0c4c7837a51c8c3b37aa970c755c5610b16e6afa82f4cfea6dfa14f347366932e4e0ded921150ad4ad349f1d16661934925da6ece7253599fbd90cf0 *commons-geometry-1.0-bin.tar.gz
b170b25f0c4c7837a51c8c3b37aa970c755c5610b16e6afa82f4cfea6dfa14f347366932e4e0ded921150ad4ad349f1d16661934925da6ece7253599fbd90cf0  commons-geometry-1.0-bin.tar.gz

两行哈希一致,包完整可信。包大小实测 8283160 字节。

5.3 解压与目录结构

解压并规范到 /opt/commons-geometry/1.0:

mkdir -p /opt/commons-geometry
cd /opt/commons-geometry
tar xzf /opt/commons-geometry-1.0-bin.tar.gz
mv commons-geometry-1.0 /opt/commons-geometry/1.0
ls /opt/commons-geometry/1.0/*.jar

输出:

/opt/commons-geometry/1.0/commons-geometry-core-1.0-javadoc.jar
/opt/commons-geometry/1.0/commons-geometry-core-1.0-sources.jar
/opt/commons-geometry/1.0/commons-geometry-core-1.0.jar
/opt/commons-geometry/1.0/commons-geometry-euclidean-1.0-javadoc.jar
/opt/commons-geometry/1.0/commons-geometry-euclidean-1.0-sources.jar
/opt/commons-geometry/1.0/commons-geometry-euclidean-1.0.jar
/opt/commons-geometry/1.0/commons-geometry-io-core-1.0-javadoc.jar
/opt/commons-geometry/1.0/commons-geometry-io-core-1.0-sources.jar
/opt/commons-geometry/1.0/commons-geometry-io-core-1.0.jar
/opt/commons-geometry/1.0/commons-geometry-io-euclidean-1.0-javadoc.jar
/opt/commons-geometry/1.0/commons-geometry-io-euclidean-1.0-sources.jar
/opt/commons-geometry/1.0/commons-geometry-io-euclidean-1.0.jar
/opt/commons-geometry/1.0/commons-geometry-spherical-1.0-javadoc.jar
/opt/commons-geometry/1.0/commons-geometry-spherical-1.0-sources.jar
/opt/commons-geometry/1.0/commons-geometry-spherical-1.0.jar

5.4 补齐第三方依赖 jar

由于 euclidean 依赖 commons-numbers-*,需一并下载到 /opt/geo-jars:

mkdir -p /opt/geo-jars
cd /opt/geo-jars
B=https://repo1.maven.org/maven2/org/apache/commons
curl -sO $B/commons-geometry-euclidean/1.0/commons-geometry-euclidean-1.0.jar
curl -sO $B/commons-geometry-core/1.0/commons-geometry-core-1.0.jar
curl -sO $B/commons-numbers-core/1.0/commons-numbers-core-1.0.jar
curl -sO $B/commons-numbers-arrays/1.0/commons-numbers-arrays-1.0.jar
curl -sO $B/commons-numbers-angle/1.0/commons-numbers-angle-1.0.jar
curl -sO $B/commons-numbers-quaternion/1.0/commons-numbers-quaternion-1.0.jar
ls -l

输出:

total 468
-rw-r--r-- 1 root root  89526 commons-geometry-core-1.0.jar
-rw-r--r-- 1 root root 303783 commons-geometry-euclidean-1.0.jar
-rw-r--r-- 1 root root  14357 commons-numbers-angle-1.0.jar
-rw-r--r-- 1 root root  12940 commons-numbers-arrays-1.0.jar
-rw-r--r-- 1 root root  25745 commons-numbers-core-1.0.jar
-rw-r--r-- 1 root root  20406 commons-numbers-quaternion-1.0.jar

5.5 手动编译运行验证

复用第 4.4 节的 GeometryCheck.java,直接以 jar 目录作为 classpath 编译并运行:

cd /opt/geo-demo
mkdir -p out2
javac -encoding UTF-8 -cp "/opt/geo-jars/*" -d out2 src/main/java/GeometryCheck.java
java -cp "out2:/opt/geo-jars/*" GeometryCheck

输出:

distance(a,b)        = 5.0
project (2,3) -> x   = (2.0, 0.0)
distance (2,3) -> x  = 3.0

验证点:结果与方案 A 完全一致。说明不依赖 Maven、纯 jar 直跑同样可用。-encoding UTF-8 用于源码含中文时避免 unmappable character 报错。

六、源码安装方案(C:官方源码编译)

适合需要定制、调试源码或跟随主线开发的场景。使用官方 src 源码包,由 Maven 编译出所有模块 jar。

6.1 方案说明与前置依赖

下载官方源码包并用 Maven 构建整个 reactor。构建需要 JDK 17(或 Java 8+)与 Maven,首次构建需联网下载构建插件。

6.2 下载与校验源码包

cd /opt
curl -sO https://downloads.apache.org/commons/geometry/source/commons-geometry-1.0-src.tar.gz
curl -sO https://downloads.apache.org/commons/geometry/source/commons-geometry-1.0-src.tar.gz.sha512
cat commons-geometry-1.0-src.tar.gz.sha512
sha512sum commons-geometry-1.0-src.tar.gz

输出:

ad2c89958a3a6278135b2c820bc5c6d97edc49ea8dd119c44c49e764248e068ff0404b04cb620d0f10a7172b69ee0907f39483119c1fcd695ffe58f4c0d3731a *commons-geometry-1.0-src.tar.gz
ad2c89958a3a6278135b2c820bc5c6d97edc49ea8dd119c44c49e764248e068ff0404b04cb620d0f10a7172b69ee0907f39483119c1fcd695ffe58f4c0d3731a  commons-geometry-1.0-src.tar.gz

哈希一致,源码包大小实测 3866337 字节。

6.3 解压与查看模块

cd /opt
tar xzf commons-geometry-1.0-src.tar.gz
ls commons-geometry-1.0-src

输出:

CONTRIBUTING.md
LICENSE.txt
NOTICE.txt
README.md
RELEASE-NOTES.txt
commons-geometry-core
commons-geometry-euclidean
commons-geometry-examples
commons-geometry-io-core
commons-geometry-io-euclidean
commons-geometry-spherical

6.4 编译构建

执行 Maven 构建(跳过测试以加快速度):

cd /opt/commons-geometry-1.0-src
mvn -B -DskipTests package

输出节选(实测首尾):

[INFO] Building jar: /opt/commons-geometry-1.0-src/commons-geometry-io-euclidean/target/commons-geometry-io-euclidean-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache Commons Geometry 1.0:
[INFO]
[INFO] Apache Commons Geometry ............................ SUCCESS [04:06 min]
[INFO] Apache Commons Geometry Core ....................... SUCCESS [ 37.231 s]
[INFO] Apache Commons Geometry Euclidean .................. SUCCESS [  4.122 s]
[INFO] Apache Commons Geometry Spherical .................. SUCCESS [  1.280 s]
[INFO] Apache Commons Geometry IO Core .................... SUCCESS [  1.117 s]
[INFO] Apache Commons Geometry IO Euclidean ............... SUCCESS [  1.225 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] Total time:  04:51 min

验证产物 jar 是否生成:

find /opt/commons-geometry-1.0-src -name "commons-geometry-*-1.0.jar" -not -name "*sources*" -not -name "*javadoc*" | sort

输出:

/opt/commons-geometry-1.0-src/commons-geometry-core/target/commons-geometry-core-1.0.jar
/opt/commons-geometry-1.0-src/commons-geometry-euclidean/target/commons-geometry-euclidean-1.0.jar
/opt/commons-geometry-1.0-src/commons-geometry-io-core/target/commons-geometry-io-core-1.0.jar
/opt/commons-geometry-1.0-src/commons-geometry-io-euclidean/target/commons-geometry-io-euclidean-1.0.jar
/opt/commons-geometry-1.0-src/commons-geometry-spherical/target/commons-geometry-spherical-1.0.jar

验证点:5 个模块 jar 全部生成,BUILD SUCCESS。

七、方案对比与选择建议

三种方案各有取舍,本节汇总关键差异并给出选型建议。

维度方案 A:Maven 依赖方案 B:二进制包方案 C:源码编译
是否需联网构建时需联网仅下载阶段需联网构建时需联网
安装方式声明依赖自动解析手动解压 + 补 jarMaven 构建 reactor
依赖完整性自动含全部传递依赖需手动补 commons-numbers-*自动构建全部模块
耗时最短(秒级)短最长(实测约 5 分钟)
适用场景CI/可联网开发内网隔离、离线运行源码定制、调试、跟主线
验证结果与 B、C 一致与 A、C 一致与 A、B 一致

选择建议:可联网优先方案 A(最简单、依赖自动解析);内网隔离选方案 B(一次下载即可离线运行);需要改源码或跟随新版本选方案 C。三方案的 GeometryCheck 实测输出一致,可放心互换。

八、配置说明

库本身无独立配置文件,运行期需要关注的“配置”集中在 JDK/Maven 环境与编码,本节逐项说明。

  • JDK 版本:Commons Geometry 1.0 要求 Java 8+;实测在 JDK 17.0.20.1 正常工作。
  • Maven JAVA_HOME:多 JDK 并存时需确保 Maven 使用目标 JDK。Ubuntu 下系统 Maven 直接使用 java 解析出的 JDK,实测无需额外设置。
  • 源码文件编码:Java 源码含中文注释时,javac 需带 -encoding UTF-8(见 5.5),否则报 unmappable character ... for encoding US-ASCII。Maven 工程则由 project.build.sourceEncoding 统一控制。
  • 依赖坐标:groupId 固定 org.apache.commons,常用 artifact 为 commons-geometry-euclidean(传递引入 commons-geometry-core 与 commons-numbers-*)。

九、常见问题(FAQ)

Q1:mvn compile 报 invalid target release: 17 怎么办?

这是 Maven 使用了低于 17 的 JDK 所致。确认当前 Maven 使用的 JDK:

mvn -version | grep "Java version"

输出:

Java version: 17.0.20.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64

若显示非 17,安装 JDK 17 并确保 java -version 为 17。本环境实测为 17,可直接编译。

Q2:javac 报 unmappable character (0xE6) for encoding US-ASCII 怎么办?

源码含中文且默认平台编码为 US-ASCII 所致,加 -encoding UTF-8:

javac -encoding UTF-8 -cp "/opt/geo-jars/*" -d out2 src/main/java/GeometryCheck.java

输出(无错误即通过):

(无输出,编译通过)

Q3:运行报 NoClassDefFoundError: org/apache/commons/numbers/core/Precision 怎么办?

缺少 commons-numbers-core 依赖。方案 B 手动 jar 时务必补齐 5.4 节列出的 5 个 jar;方案 A/C 由 Maven 自动解析,无需处理。

Q4:不知道某个类在哪个模块里,怎么快速定位?

用 jar tf 检索 jar 内条目。例如查找 2D 直线相关类:

jar tf /opt/geo-jars/commons-geometry-euclidean-1.0.jar | grep "euclidean/twod/[A-Z].*\.class" | grep -v '\$' | head -12

输出:

org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2D.class
org/apache/commons/geometry/euclidean/twod/BoundaryList2D.class
org/apache/commons/geometry/euclidean/twod/BoundarySource2D.class
org/apache/commons/geometry/euclidean/twod/BoundarySourceBoundsBuilder2D.class
org/apache/commons/geometry/euclidean/twod/BoundarySourceLinecaster2D.class
org/apache/commons/geometry/euclidean/twod/Bounds2D.class
org/apache/commons/geometry/euclidean/twod/ConvexArea.class
org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubset.class
org/apache/commons/geometry/euclidean/twod/Line.class
org/apache/commons/geometry/euclidean/twod/LineConvexSubset.class
org/apache/commons/geometry/euclidean/twod/LineSpanningSubset.class
org/apache/commons/geometry/euclidean/twod/LineSubset.class

十、卸载与清理

删除源码包、二进制包、手动 jar 与示例工程即可完全清理,库不做系统级安装:

rm -rf /opt/geo-demo /opt/geo-jars /opt/commons-geometry /opt/commons-geometry-1.0-src /opt/commons-geometry-1.0-bin.tar.gz /opt/commons-geometry-1.0-bin.tar.gz.sha512
ls -d /opt/geo-demo 2>/dev/null || echo "geo-demo removed"

输出:

geo-demo removed

如需同时移除 JDK 与 Maven:

DEBIAN_FRONTEND=noninteractive apt-get remove -y openjdk-17-jdk maven

输出节选(实测首尾):

Reading package lists...
Building dependency tree...
...
Removing maven (3.6.3-5) ...

⚠️ 注意:apt-get remove 仅移除软件包,本地 Maven 仓库缓存 ~/.m2 需另行清理(rm -rf ~/.m2/repository)。

十一、参考链接

  1. Apache Commons Geometry 官方站点:https://commons.apache.org/proper/commons-geometry/
  2. 官方发行下载目录:https://downloads.apache.org/commons/geometry/
  3. 历史版本归档目录:https://archive.apache.org/dist/commons/geometry/
  4. Maven 中央仓库坐标页:https://repo1.maven.org/maven2/org/apache/commons/commons-geometry-euclidean/
  5. Apache Commons Geometry 用户指南(含于二进制包 docs/userguide/):https://commons.apache.org/proper/commons-geometry/userguide/index.html