Building JMathAnim

JMathAnim is a Maven multi-module project:

Module Artifact Purpose
jmathanim-core jmathanim-core-<version>.jar The animation library (Java + Groovy + the DSL)
jmathanim-gui jmathanim-gui-<version>.jar The Swing script editor, depends on the core

Prerequisites

  • JDK 17 or newer (the code targets Java 11, but JavaFX 17 and the release scripts assume a modern JDK; JDK 21 is what the installers are built with).
  • Maven 3.8+ (mvn -v to check).
  • An internet connection for the first build: Maven downloads JavaFX, JavaCV/FFmpeg, Groovy, JLaTeXMath and Batik.
  • Optional, only for LaTeX objects at runtime: a working latex installation.

No JavaFX SDK has to be installed by hand. The JavaFX jars are ordinary Maven dependencies of the core module and are resolved automatically for your platform.

All commands below are run from the repository root.


1. Building the core jar (to use as a library)

mvn -pl jmathanim-core -am clean package -DskipTests -Dgpg.skip=true

What you get in jmathanim-core/target/:

  • jmathanim-core-<version>.jar - the library itself.
  • jmathanim-core-<version>-sources.jar and -javadoc.jar.
  • lib/ - every runtime dependency, copied there by maven-dependency-plugin. You need these jars on the classpath when you use the core jar outside Maven.

-Dgpg.skip=true is needed because the parent POM signs artifacts in the verify phase; skip it unless you have a GPG key set up for releases.

Installing it into your local Maven repository

The parent POM sets maven.install.skip=true, so you must turn it off explicitly:

mvn -pl jmathanim-core -am clean install -DskipTests -Dgpg.skip=true -Dmaven.install.skip=false

Then depend on it from another project:

<dependency>
    <groupId>com.github.davidgutierrezrubio</groupId>
    <artifactId>jmathanim-core</artifactId>
    <version>1.4.7</version>
</dependency>

Platform profiles

By default the library profile is active and pulls ffmpeg-platform-gpl, which contains the native FFmpeg binaries for all platforms (large, but convenient for development). For a slim build, activate a single-platform profile:

mvn -pl jmathanim-core -am clean package -DskipTests -Dgpg.skip=true -P windows

Available: windows, linux, macos-arm64, macos-x86_64.

Running a Groovy script without the GUI

java -cp "jmathanim-core/target/jmathanim-core-1.4.7.jar;jmathanim-core/target/lib/*" com.jmathanim.core.groovy.GroovyExecutor myscript.groovy

On Linux/macOS use : instead of ; as the classpath separator.


2. Building and running the graphical editor

Build both modules (the GUI needs the core version declared in its core.version property, so build the reactor with -am):

mvn clean package -DskipTests -Dgpg.skip=true

Output in jmathanim-gui/target/:

  • jmathanim-gui-<version>.jar
  • lib/ - all runtime dependencies, including the freshly built core jar.

The quick way: the launcher scripts

Two scripts in the repository root do the whole thing (build the modules if they have not been packaged yet, then start the editor):

jmathanim-editor.bat
./jmathanim-editor.sh

jmathanim-editor.bat is for Windows, jmathanim-editor.sh for Linux and macOS (chmod +x jmathanim-editor.sh the first time). Both accept:

  • --build - force mvn package even if the jars are already there.
  • any other argument, which is forwarded to the launcher, notably --no-log-file to keep the output on the terminal instead of a log file.

They honour the MAVEN_EXE and JAVA_EXE environment variables if you need a specific Maven or JDK. The rest of this section describes what they do by hand.

Running it manually

The jar has no Class-Path in its manifest, so java -jar is not enough; put lib/ on the classpath:

java -cp "jmathanim-gui/target/jmathanim-gui-1.9.4.jar;jmathanim-gui/target/lib/*" com.jmathanimgui.app.Launcher

Linux/macOS:

java -cp "jmathanim-gui/target/jmathanim-gui-1.9.4.jar:jmathanim-gui/target/lib/*" com.jmathanimgui.app.Launcher

Launcher is the recommended entry point: it looks for a newer jmathanim-core-X.Y.Z.jar in ~/.jmathanim/lib/ and loads it instead of the bundled one, and it redirects System.out/System.err to a log file. Pass --no-log-file to keep the output on the console, which is handy while developing. com.jmathanimgui.app.JMathAnimGUI (the manifest main class) starts the editor directly, without the core-swapping logic.

If Groovy complains about reflective access on a recent JDK, add the same --add-opens flags the installer uses:

java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED -cp "jmathanim-gui/target/jmathanim-gui-1.9.4.jar;jmathanim-gui/target/lib/*" com.jmathanimgui.app.Launcher

Running it from Maven

The gui profile configures the JavaFX plugin, so the editor can also be started without assembling a classpath by hand:

mvn -pl jmathanim-gui -am -P gui javafx:run

3. Native installers

build-windows.py, build-linux.py and build-macos.py at the repository root wrap jpackage to produce self-contained installers. They are not part of the Maven build: edit the constants at the top of the script (JDK path, JavaFX SDK path, build directory) to match your machine before running them, for example:

python build-windows.py

Tests

mvn test

Both modules use JUnit 5 with Surefire 3.2.5. Drop -DskipTests from any of the commands above to run them as part of the build.