Open folder
Open your practice folder in the agent chat.
You will create a small program that listens on localhost and returns JSON data. The agent helps you learn java data structures properly while writing the code, compiling it, and running the server so you can see the results in your browser.
Open your practice folder in the agent chat.
Ask the agent to create the server class.
Run the compiler to check for errors.
Start the server and check the output.
Counter.javasavedCounter.java2 editsjavac Counter.javaexit 0java CounterConnectedimport java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(8080);
while (true) {
Socket s = ss.accept();
System.out.println("Connected");
s.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}This class contains a main method, an int field, and a for loop that prints a result.
You start by writing a small program that acts as your backend and the agent uses write_file to create the main class for your java rest api project. Edit the logic. A java course for strong fundamentals helps you understand the structure. The agent uses edit_file to add the logic for handling requests. You can use the standard library to format the response as JSON. The agent then runs the Java compiler to show compiler errors. You review the diff in Ask first mode to see exactly what changed. This approach helps you understand the structure of a java rest api without getting overwhelmed.
You can test the running server with a simple client and the agent helps you write a test command that sends a request to localhost. This works. A java microservices tutorial shows how to split the app into two small programs that talk over HTTP. You should always check the output to ensure the response matches your expectations. The agent can list the files in your folder to confirm everything is in place. This exercise teaches you how services communicate with each other over HTTP. The best way to learn java is by doing these small exercises yourself. The agent explains code step by step and points out likely causes of errors.