Use Claude Agent, Copilot or Junie Inside IntelliJ IDEA
Open IntelliJ's AI Chat, pick Claude Agent (the agent behind Claude Code) or Copilot and a model, ask in plain words for Main.java to print the date and time, review the change, and run it.
What you will learn
- Open the AI Chat panel in IntelliJ IDEA and sign in once
- Pick an agent (Claude Agent, Copilot, Junie) and a model
- Explain what a coding agent does between your prompt and the file change
- Review an agent's edit, keep or roll it back, then run the code
Before you start
- JDK 25 and IntelliJ IDEA installed
IntelliJ IDEA has an AI Chat panel where several coding agents live side by side: Claude Agent (the agent behind Claude Code), GitHub Copilot, Codex, Junie by JetBrains and more. You open the panel, pick an agent and a model, ask for a change in plain words, and the agent edits the real files in your project.
This walk-through uses one small prompt on a sample project. The same panel handles much bigger jobs later, when you build a full web application.
Step 1: a small Java project
The AI features come from plugins. On the IntelliJ welcome screen, open Plugins: the AI Assistant plugin gives you the AI Chat, and the GitHub Copilot plugin is there too. If you can't find the AI Chat later, come back here, search for AI Assistant, install it and restart the IDE.
Then click New Project:
- Keep Java selected on the left and give it a name. The lecture uses
aicode. - Build system: IntelliJ, the simplest one. Maven comes later.
- JDK: your JDK 25.
- Keep Add sample code ticked, so you get a
Main.javato work with.
Click Create and the project opens. The sample Main.java prints a welcome line, then a loop prints i from 1 to 5.
Step 2: open the AI Chat and pick an agent
Look at the right edge of the window and click the AI Chat icon. The panel says "Pair your IDE intelligence with AI" and lists the agents:
- Claude Agent: Anthropic's coding agent, the same one behind Claude Code, running inside IntelliJ.
- GitHub Copilot: asks you to sign in with your GitHub account.
- Codex and Junie, the agent made by the JetBrains team. "More agents" lists many others.
You can also plug in a third-party provider with your own key, or a model running on your own machine, such as LM Studio.
Step 3: sign in once
Click the AI Assistant icon in the top bar. The first time, IntelliJ asks you to log in with your JetBrains account. The free quota is limited; a paid subscription gives you more. If you already have your own key (from Anthropic, for example), open Providers and API keys and add it there.
When that's done, the chat shows Claude Agent with "configured authentication: JetBrains". It's ready.
Step 4: choose the agent and the model
Under the prompt box there's a drop-down with the agent list: Claude Agent, Codex, Cursor, Gemini CLI, GitHub Copilot and Junie. You can switch any time. Junie is different in one way: you don't pick its model, it chooses one per task.
With Claude Agent you also pick the model: Opus, Sonnet or Haiku. For a small task, Sonnet is plenty. Version numbers change over time, so yours may look different. Below that is reasoning, how much the model thinks before it answers. Leave it on default.
What an agent does with your prompt
Before you send anything, it helps to know what happens in between.
You write the prompt. The agent (Claude Agent, Copilot or Junie) plans the steps, using the model you picked for the thinking. Then it works on your real project: it reads Main.java and edits it. Those are real files and real changes. Finally the result comes back to you to review, keep or roll back, and run.
Step 5: prompt the agent
The prompt in the lecture is one plain sentence:
update my main.java and display date and time
That's enough. (It was dictated with a speech-to-text tool; typing works the same.) The bottom of the panel shows the agent and model, Claude Agent and Sonnet, and the permission mode.
The lecture's machine runs in bypass permissions, so the agent edits without asking. While you're learning, keep the default mode, where the agent asks before it changes a file. Then you see every change before it happens.
Click Send. The agent starts thinking and reads the project first.
Step 6: review the change
The chat shows what the agent did: it read Main.java, then edited it, "+10 lines". Below that it explains the change: it added a date-and-time line after the welcome message, formatted as year, month, day, then hours, minutes and seconds. It also says it hasn't run the code. Running it is your job.
In the editor, the new lines use a LocalDateTime for the current moment, a DateTimeFormatter for the format, and a print line that uses both. The existing code stayed as it was.
At the bottom you get Done and Rollback. Rollback puts the file back the way it was. This change looks right, so keep it.
Step 7: run it
Click the green arrow next to void main and choose Run 'Main.main()', or press Shift+F10. The Run window prints the welcome line, then the current date and time of the run, and the loop still prints i from 1 to 5. The agent changed exactly what was asked and left the rest alone.
Common mistakes
- No AI Chat icon. The AI Assistant plugin isn't installed. Install it from Plugins and restart.
- Learning in bypass mode. You miss every change. Keep the default "ask before editing" mode until you're comfortable reading diffs.
- Trusting without running. The agent itself said it hadn't run the code. Always run it and check the output.
- Reaching for the biggest model. A one-file change doesn't need Opus. Sonnet handles it.
Recap
| Step | Where | What to remember |
|---|---|---|
| Plugins | Welcome screen | AI Assistant gives you the AI Chat |
| Sign in | AI Assistant icon, top bar | JetBrains account, or your own API key |
| Agent and model | Drop-down under the prompt | Claude Agent + Sonnet for small tasks; Junie picks its own model |
| Prompt | Prompt box | Plain words, default permission mode |
| Review | Chat + editor | Done or Rollback |
| Run | Green arrow or Shift+F10 | Check the output yourself |
Try it yourself: on the same sample project, ask the agent to print the loop numbers in reverse, review the diff, and roll it back if it touched anything you didn't ask for. For a wider look at the agents themselves, see Coding Agents Compared.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE
Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)Related posts
Install Java 25 (JDK) and IntelliJ IDEA, Then Run Your First Program
Install JDK 25 (Microsoft Build of OpenJDK) with JAVA_HOME, install IntelliJ IDEA, then point a run configuration at the JDK and the main class and run Hello World.
Java Hello World with Maven: What the JDK Does and What Maven Adds
javac compiles HelloWorld.java into bytecode and java runs it on the JVM. Maven adds one pom.xml, the same folders in every project and one build command. Then a real Maven Hello World in IntelliJ.
Java Variables, Keywords and Naming Rules
A variable is a labelled jar that holds one value at a time. Four small programs show declaring, reassigning, the names Java accepts, the keywords it reserves, and why daysUntilLaunch beats d.
Maven in IntelliJ: pom.xml, Dependencies and the Build Lifecycle
Open a plain project and a Maven project in IntelliJ, read an invoice app's pom.xml, follow jackson-databind from Maven Central into ~/.m2, and see why each lifecycle phase runs the ones before it.
