Skip to the content.

← Back to Home

JAR Build for SmallTextPad

This guide covers building the standalone JAR file for SmallTextPad, a lightweight Java text editor with encryption and multi-language support.

Files

Prerequisites

System Requirements

Installing Build Dependencies

Fedora/RHEL/CentOS:

sudo dnf install java-21-openjdk-devel

Ubuntu/Debian:

sudo apt install openjdk-21-jdk

openSUSE:

sudo zypper install java-21-openjdk-devel

macOS:

brew install openjdk@21

Building the JAR File

The build script can be run from anywhere in the project:

From Project Root:

./packaging/build-jar.sh

From Packaging Directory:

cd packaging
./build-jar.sh

The script will:

  1. Navigate to the project root automatically
  2. Delete any existing compiled class files
  3. Generate a list of all Java source files
  4. Compile all Java sources to the bin/ directory
  5. Copy resource bundles (.properties files) to the correct package structure
  6. Copy image resources to the JAR root for classpath access
  7. Copy dictionary files for spell-checking
  8. Create the JAR file with proper manifest
  9. Test launch the application

Build Output

After successful build:

Running the JAR

Direct Execution:

java -jar classes/artifacts/SmallTextPad.jar

With File Argument:

java -jar classes/artifacts/SmallTextPad.jar /path/to/file.txt

Using Desktop Environment:

On systems with desktop integration, you can double-click the JAR file if .jar files are associated with Java.

JAR Contents

The JAR file includes:

Distribution

The generated JAR is a fully self-contained executable that can be:

Troubleshooting

Build Fails - javac not found:

Ensure Java JDK is installed and javac is in your PATH:

which javac
javac -version

Application Doesn’t Launch:

Verify Java runtime is installed:

java -version

Missing Resources Error:

If you see MissingResourceException or NullPointerException for resources:

  1. Clean and rebuild:
    rm -rf bin/ classes/artifacts/
    ./packaging/build-jar.sh
    
  2. Verify JAR contents:
    jar tf classes/artifacts/SmallTextPad.jar | grep -E "(\.properties$|\.png$)"
    

Permission Denied:

Make the script executable:

chmod +x packaging/build-jar.sh

Development Workflow

For rapid development and testing:

  1. Edit source files in src/ directory
  2. Run build script to compile and test:
    ./packaging/build-jar.sh
    
  3. Application launches automatically for testing
  4. Close application and repeat as needed

The script automatically cleans previous builds, so you always get a fresh compile.

Notes

See Also