# Run the quick setup script
./setup.sh
# Now use the formatter
./eclipse-format --help# Build and install with interactive menu
./install.sh
# Choose installation option (system-wide, local, or standalone)# Build the project
./gradlew shadowJar
# Run directly
java -jar build/libs/eclipse-format.jar --help
# Or use the universal wrapper
./eclipse-format.sh --helpThe most user-friendly way to install the tool.
./install.shFeatures:
- Interactive menu with installation options
- System-wide installation (requires sudo)
- Local user installation (~/.local/bin)
- Standalone script creation
- Java version checking
- Automatic PATH configuration
Smart wrapper that automatically finds the JAR file.
# Basic usage (auto-finds JAR)
./eclipse-format.sh MyClass.java
# Specify JAR explicitly
./eclipse-format.sh --jar-path /path/to/jar -r src/
# Utility commands
./eclipse-format.sh --find-jar # Search for JAR files
./eclipse-format.sh --install-info # Show installation info
./eclipse-format.sh --self-update # Update wrapper (if installed via package)For Windows users (requires Java installed).
eclipse-format.bat MyClass.java
eclipse-format.bat --jar-path C:\path\to\jar -r src\Creates a simple wrapper in the current directory.
./setup.sh
# Creates ./eclipse-format wrapper./install.sh
# Choose option 1 (system-wide)
# Requires sudo privilegesResult: Installs to /usr/local/bin/eclipse-format
./install.sh
# Choose option 2 (local)Result: Installs to ~/.local/bin/eclipse-format
./install.sh
# Choose option 3 (standalone)Result: Creates eclipse-format-standalone.sh that can be distributed separately
# Just build and use from project directory
./gradlew shadowJar
./eclipse-format.sh MyClass.java# Install Java if needed
brew install openjdk@17
# Install formatter
./install.sh
# Add to PATH if using local installation
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc# Install Java if needed (Ubuntu/Debian)
sudo apt install openjdk-17-jdk
# Install formatter
./install.sh
# Verify installation
which eclipse-format
eclipse-format --version# Install Java from https://adoptium.net/
# Add Java to PATH
# Build the project
gradlew.bat shadowJar
# Use the batch wrapper
eclipse-format.bat --help
# Or create a shortcut:
# 1. Create eclipse-format.bat with: java -jar "C:\path\to\eclipse-format.jar" %*
# 2. Add the directory to your PATHYou can customise behaviour with environment variables:
# Specify JAR location explicitly
export ECLIPSE_FORMATTER_JAR="/path/to/eclipse-format.jar"
# Custom Java options (memory, etc.)
export JAVA_OPTS="-Xmx2g -XX:+UseG1GC"
# The wrapper will use these automatically
eclipse-format.sh MyClass.javaeclipse-format MyClass.javaeclipse-format -r src/eclipse-format -d -r src/# Export from Eclipse: Window → Preferences → Java → Code Style → Formatter → Export
eclipse-format -c my-config.xml MyClass.java# Check if code is properly formatted
eclipse-format -d -r src/
if [ $? -eq 0 ]; then
echo "✅ Code is properly formatted"
else
echo "❌ Code needs formatting"
exit 1
fiAdd to .git/hooks/pre-commit:
#!/bin/bash
echo "Formatting Java files..."
eclipse-format -r src/
git add src/# Check Java installation
java -version
# Install Java if missing
# macOS: brew install openjdk@17
# Ubuntu: sudo apt install openjdk-17-jdk# Build the project first
./gradlew shadowJar
# Or use the find command
./eclipse-format.sh --find-jar# Make scripts executable
chmod +x *.sh
# For installation, use sudo
sudo ./install.sh- Install Java from https://adoptium.net/
- Add Java to PATH:
C:\Program Files\Eclipse Adoptium\jdk-17.0.x\bin - Restart command prompt
git pull origin main
./gradlew shadowJar
./install.sh # Re-run installer if needed./eclipse-format.sh --self-update# Interactive uninstall (recommended)
./uninstall.sh
# Or use specific options:
./uninstall.sh --system # Remove system-wide installation
./uninstall.sh --local # Remove local user installation
./uninstall.sh --all # Remove ALL installations
./uninstall.sh --clean-path # Clean up PATH entries
./uninstall.sh --specific /path/to/file # Remove specific file
# Show help
./uninstall.sh --help# The install script also has uninstall options
./install.sh
# Choose option 5 (Uninstall)sudo rm /usr/local/bin/eclipse-format
sudo rm /usr/local/bin/eclipse-format.jarrm ~/.local/bin/eclipse-format
rm ~/.local/bin/eclipse-format.jar
rm ~/bin/eclipse-format 2>/dev/null || true
rm ~/bin/eclipse-format.jar 2>/dev/null || trueEdit your shell config file (~/.bashrc, ~/.zshrc, or ~/.profile) and remove any lines containing:
export PATH="$HOME/.local/bin:$PATH"export PATH=$HOME/.local/bin:$PATHexport PATH="$HOME/bin:$PATH"# Eclipse Formatter CLI
For issues or questions:
- Check this USAGE.md file
- Run
./eclipse-format.sh --install-info - Check the README.md for more details
- File an issue on GitHub
Pro Tip: For the best experience, use ./install.sh and choose system-wide or local installation. The wrapper scripts handle all the complexity for you!