IntelliJ IDEA Integration
IntelliJ IDEA Integration
Section titled “IntelliJ IDEA Integration”Use LeanJ directly in IntelliJ IDEA to see performance metrics in your code editor.
Prerequisites
Section titled “Prerequisites”- IntelliJ IDEA 2023.1+ (2025.2 tested)
- LeanJ CLI installed and in PATH (or configured via system property)
- Java JDK 11+ for the profiled application
Installation
Section titled “Installation”Install the Plugin
Section titled “Install the Plugin”- In IntelliJ IDEA, go to File → Settings → Plugins
- Search for “LeanJ”
- Click Install
- Restart IDE when prompted
Configure CLI Path
Section titled “Configure CLI Path”The plugin needs to find the CLI. It searches in this order:
- System property:
-Dleanj.cli.path=<path> - PATH environment variable
- Plugin bundle (future)
Set system property:
- Go to Help → Edit Custom VM Options…
- Add:
-Dleanj.cli.path=C:\path\to\leanj.exe - Restart IDE
Or add CLI to PATH (recommended):
- See Installation Guide for PATH setup
Method 1: Automatic (Recommended)
Section titled “Method 1: Automatic (Recommended)”- Start LeanJ Profiling:
- Go to Run → Start LeanJ Profiling
The plugin automatically:
- Calls the CLI
- Starts the controller (if not running)
- Discovers JVMs
- Attaches the agent
-
Run your application:
- Use your normal Run Configuration
- The agent is already attached
-
View metrics:
- Open your Java files
- See inline hints above methods
- Hover for detailed popup
- Check the Profiler tool window
Method 2: Manual CLI + IDE
Section titled “Method 2: Manual CLI + IDE”-
Start controller manually:
Terminal window leanj controller start -
Discover JVMs:
Terminal window leanj jvms -
Attach agent:
Terminal window leanj attach --pid <pid> -
Start profiling in IntelliJ:
- Run → Start LeanJ Profiling
Viewing Metrics
Section titled “Viewing Metrics”CodeVision Inline Hints
Section titled “CodeVision Inline Hints”Metrics appear directly above method declarations:
╰─ Estimated avg execution time: 2.1ms╰─ Max time last run: 4.8ms╰─ Allocations per call: ~12KB╰─ Call count: 150╰─ Trend: +15%
public void processPayments() { // your code}Hover Popup
Section titled “Hover Popup”Hover over a method to see detailed metrics:
- Average execution time
- Maximum time
- Allocations
- Call count
- Trend (percentage change)
- Context information
Profiler Tool Window
Section titled “Profiler Tool Window”- Open View → Tool Windows → Profiler
- Or click the Profiler tab at the bottom
The tool window shows:
- All profiled methods
- Real-time statistics
- Filtering and sorting options
Metrics Explained
Section titled “Metrics Explained”Average Execution Time
Section titled “Average Execution Time”Cumulative average from profiling start. Shows typical performance.
Max Time
Section titled “Max Time”Maximum execution time in the last measurement window. Helps identify outliers.
Allocations
Section titled “Allocations”Memory allocated per call. Useful for finding memory-intensive operations.
Call Count
Section titled “Call Count”Total number of method invocations since profiling started.
Percentage change compared to previous measurement. Positive means slower, negative means faster.
CodeVision Settings
Section titled “CodeVision Settings”Enable CodeVision in IntelliJ:
- File → Settings → Editor → Inlay Hints
- Enable Code Vision
- Enable LeanJ hints
Multiple JVM Support
Section titled “Multiple JVM Support”You can profile multiple JVMs simultaneously:
-
Attach to multiple JVMs using CLI:
Terminal window leanj attach --pid 12345leanj attach --pid 67890 -
The plugin shows metrics from all attached JVMs
-
Metrics are aggregated per method
Docker JVMs
Section titled “Docker JVMs”Docker containers with the agent automatically appear in the JVM list:
-
Ensure agent is configured in Dockerfile:
ENV JAVA_TOOL_OPTIONS="-javaagent:/agent/agent.jar"ENV LEANJ_PROJECT=my-service -
Container starts and registers with controller
-
Appears in
leanj jvmsoutput -
Plugin can attach and show metrics
Troubleshooting
Section titled “Troubleshooting”CLI Not Found
Section titled “CLI Not Found”Error: CLI not found
Solution:
- Verify CLI is installed: See Installation Guide
- Check CLI is in PATH:
leanj --version - Add to PATH or set system property:
-Dleanj.cli.path=<path> - Restart IDE
Controller Not Running
Section titled “Controller Not Running”Error: Controller not running
Solution:
- Start controller manually:
leanj controller start - Or let plugin start it automatically
- Check logs:
logs/profiler-controller.log
No Metrics Visible
Section titled “No Metrics Visible”Issue: CodeVision hints not showing
Solution:
- Enable CodeVision: Settings → Editor → Inlay Hints
- Ensure agent is attached:
leanj status - Check controller logs for errors
- Verify application is running and being profiled
Metrics Not Updating
Section titled “Metrics Not Updating”Issue: Metrics are stale
Solution:
- Check controller is receiving data:
leanj status - Verify agent is connected: check controller logs
- Restart profiling: Run → Start LeanJ Profiling
Advanced Configuration
Section titled “Advanced Configuration”Custom Controller Port
Section titled “Custom Controller Port”Set environment variable:
export LEANJ_CONTROLLER_PORT=8888Or use CLI:
leanj controller start --port 8888Workspace Matching
Section titled “Workspace Matching”The CLI automatically matches JVMs to your workspace:
- Compares Git root
- Matches IDE workspace path
- Uses
user.dircomparison
This helps identify the correct JVM when multiple are running.
Next Steps
Section titled “Next Steps”- Learn about Docker integration
- Explore CLI commands
- Configure advanced settings
- Read How It Works for architecture details