3.1 KiB
3.1 KiB
jtop Project Report
Overview
jtop is a terminal-based system monitoring tool written in Java. It provides a lightweight alternative to the top command, featuring a modular and extensible interface.
Features Implemented
- CPU, memory, disk, and network usage monitoring
- Process list with scrollable interface
- Sorting by CPU, memory, PID, name, path, and other headers
- Temperature monitoring (via
/sys/class/hwmonor/sys/class/thermal) - Terminal-size adaptive display
- Keyboard navigation:
j/kto scroll,Enterfor page scroll,qorCtrl+Cto quit
Class Structure
Main— Entry point; sets up the terminal and refresh loopShowProcesses— Collects and manages running process dataProcessRow— Represents a single process entryProcessTableRenderer— Draws the process table in the terminalProcessSorter— Provides comparators for sortingMemoryInfo,CpuInfo,DiskInfo,NetworkInfo,TemperatureInfo,Uptime, etc. — System metrics modulesHeader— Displays header informationInputHandler— Reads and handles keyboard and mouse inputTerminalSize— Detects terminal dimensionsRefreshThread— Handles background refresh of process dataPathInfo— Retrieves process path and name
Design Considerations
- Modular architecture with clear separation of data collection, rendering, and input handling
- Uses Java 21+ features and the ProcessHandle API
- Layout adapts dynamically to terminal size to prevent overflow
- Graceful handling of missing or inaccessible process information
- Keyboard navigation inspired by tools like
lessandtop
Usage
Compile and run:
javac src/*.java
java src/Main.java
For system-wide installation, use the included build.sh and install.sh scripts.
Keyboard shortcuts:
j/k: scroll up/downEnter: scroll one pageqorCtrl+C: quit
Code Quality
- Clear separation of concerns
- Proper encapsulation of fields
- Use of constructors and method overloading where appropriate
- Aggregation/composition used in
ShowProcessesand rendering classes - Interfaces used via
Comparatorfor sorting - Inheritance applied through
Threadextension inRefreshThread
Notes
- JavaDoc documentation can be generated using
./generate_javadoc.sh - The project is in an alpha stage — some metrics may not work on all hardware
- Tested primarily on Linux systems with Intel and AMD CPUs
TODOs / Known Issues
Tab View
- Planned implementation of a tab system to allow grouping of process information
Config
- Config file support is partially implemented — some fields (e.g.,
table.header.content) are not yet parsed or applied - Configs are not yet accessible in system-wide installations
Performance / Design
- On some terminals with custom themes, colors may display incorrectly
- Cursor animations can cause slight lag during refresh
- Table caching occasionally fails, causing unnecessary redraws and performance drops
- On low-performance machines, keyboard input may experience minor delay
Author
- Jürg Georg Hallenbarter
- Version 1.0 — Date: 2025-10-24