This guide walks you through analyzing a COBOL/JCL project and viewing the results in the web UI.
The analysis pipeline:
- Scans your COBOL (.cbl), JCL (.jcl), and Copybook (.cpy) files
- Parses JCL files to extract job/step/program relationships
- Generates ASTs (Abstract Syntax Trees) for each COBOL program
- Extracts metadata about copybook usage from the ASTs
- Produces JSON files that power the web UI
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your Mainframe Code β
β βββββββββββ βββββββββββ βββββββββββ β
β β .cbl β β .jcl β β .cpy β β
β β files β β files β β files β β
β ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β
βββββββββΌβββββββββββββββΌβββββββββββββββΌββββββββββββββββββββββββββββ
β β β
ββββββββββββββββΌβββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββ
β scan_and_analyze_project.sh β
ββββββββββββββββ¬ββββββββββββββββ
β
ββββββββββββββββ΄ββββββββββββββββ
β Output (./out) β
β β’ project-analysis.json β
β β’ jcl-analysis.json β
β β’ copybook-analysis.json β
β β’ report/ (ASTs per program) β
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββ
β smojol-ui β
β (Web-based Explorer) β
ββββββββββββββββββββββββββββββββ
The COBOL parser requires Java 21 or higher.
# macOS (Homebrew)
brew install openjdk@21
# Verify
java -versionThe JCL parser and some analysis scripts require Python with specific packages.
cd /path/to/cobol-rekt
# Create virtual environment
python3 -m venv .venv
# Activate it
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
# Install dependencies
pip install -r smojol_python/requirements.txt
pip install legacylens-jcl-parser# Build the Java components
mvn clean package -DskipTests# Make sure Java 21 is in your PATH
export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH" # macOS with Homebrew
# Run the analysis
./scripts/scan_and_analyze_project.sh <cobol_dir> <jcl_dir> <copybook_dir> <output_dir>./scripts/scan_and_analyze_project.sh \
/path/to/project/app/cbl \
/path/to/project/app/jcl \
/path/to/project/app/cpy \
./out| Step | What It Does |
|---|---|
| Step 1 | Scans directories and counts files |
| Step 2 | Creates CBLβJCL mappings (which JCL calls which COBOL program) |
| Step 3 | Generates aggregated ASTs for each COBOL program (includes copybook resolution) |
| Step 4 | (Optional) Generates dependency graphs |
| Step 5 | Generates UI JSON files using the JCL parser |
After running, you'll have:
./out/
βββ project-analysis.json # CBL β JCL mappings
βββ jcl-analysis.json # Parsed JCL files (jobs, steps, datasets)
βββ copybook-analysis-complete.json # Programs with copybook metadata
βββ report/
βββ PROGRAM1.cbl.report/
β βββ ast/
β βββ aggregated/
β βββ PROGRAM1-aggregated.json
βββ PROGRAM2.cbl.report/
β βββ ...
βββ ...
cd /path/to/cobol-rekt
# Start Python's built-in HTTP server
python -m http.server 8080Navigate to:
http://localhost:8080/smojol-ui/?dataPath=./out
The UI lets you:
- Browse COBOL programs and see their JCL references and copybooks
- Browse JCL files and see their jobs, steps, and programs executed
- Browse Copybooks and see which programs use them
- Browse Datasets referenced in JCL
| Script | Purpose |
|---|---|
scripts/scan_and_analyze_project.sh |
Main orchestrator - runs the full pipeline |
scripts/generate_ui_json.py |
Generates jcl-analysis.json and copybook-analysis-complete.json |
scripts/analyze_jcl_to_cobol.py |
Creates CBLβJCL mappings (PGM= extraction) |
| File | Contents |
|---|---|
project-analysis.json |
Maps COBOL programs to the JCL files that execute them |
jcl-analysis.json |
Full JCL analysis: job names, steps, PGM references, DD statements |
copybook-analysis-complete.json |
For each program: which copybooks it uses and where |
report/*/ast/aggregated/*.json |
Full AST with inline copybook content and metadata |
| Tool | Purpose |
|---|---|
| smojol-cli (Java) | Parses COBOL and generates ASTs with copybook resolution |
| legacylens-jcl-parser (Python) | AST-based parsing of JCL files |
| smojol-ui (HTML/JS) | Web interface to explore the analysis results |
Generate visual dependency graphs (requires graphviz):
./scripts/scan_and_analyze_project.sh ... -gGenerate detailed timing metrics:
./scripts/scan_and_analyze_project.sh ... -m# Check your Java version
java -version
# Make sure Java 21+ is first in PATH
export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"# Make sure venv is activated and package installed
source .venv/bin/activate
pip install legacylens-jcl-parser# Build the project first
mvn clean package -DskipTests- Make sure the server is running from the project root
- Check the dataPath parameter matches your output directory
- Verify all three JSON files exist in the output directory
This repository contains many advanced features for COBOL reverse engineering (flowcharts, Neo4J integration, LLM analysis, etc.).
For basic project analysis and visualization, you only need:
scripts/scan_and_analyze_project.shscripts/generate_ui_json.pysmojol-ui/
The other modules (smojol-toolkit, smojol-core, etc.) power the underlying analysis but you don't need to interact with them directly.