Yes, it is completely possible to create a server in Java without using Spring, Jakarta EE, or any other framework. Java provides built-in APIs that allow developers to create TCP, UDP, and HTTP servers directly using core Java classes. Frameworks mainly simplify development, but they are not mandatory for building server applications.
How Can We Create a Server in Core Java?
1. ServerSocket
Used for creating TCP servers.
Client
|
Socket Connection
|
ServerSocket
|
Server Processes Request
2. HttpServer
com.sun.net.httpserver.HttpServer
3. DatagramSocket
Used for UDP-based communication.
Hello World
This can be done using Java's built-in HttpServer without Spring Boot.
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpExchange;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
public class SimpleServer {
public static void main(String[] args)
throws IOException {
HttpServer server =
HttpServer.create(
new InetSocketAddress(8080),
0);
server.createContext("/hello",
(HttpExchange exchange) -> {
String response =
"Hello World";
exchange.sendResponseHeaders(
200,
response.length());
OutputStream os =
exchange.getResponseBody();
os.write(response.getBytes());
os.close();
});
server.start();
System.out.println(
"Server started on port 8080");
}
}http://localhost:8080/hello
Hello World
Creating a TCP Server Using ServerSocket
import java.net.ServerSocket;
import java.net.Socket;
public class TcpServer {
public static void main(String[] args)
throws Exception {
ServerSocket serverSocket =
new ServerSocket(8080);
System.out.println(
"Waiting for client...");
Socket client =
serverSocket.accept();
System.out.println(
"Client Connected");
}
}This creates a basic TCP server that waits for client connections.
Core Java Server vs Spring Boot
Feature Core Java Spring Boot
HTTP Server Manual Built-In
Dependency Injection No Yes
REST API Support Manual Automatic
Configuration Manual Simplified
Learning Curve Lower Higher
Development Speed Slower Faster
Enterprise Features Limited Rich
When Should You Use Core Java?
When Should You Use Spring Boot?
Real-World Example
Spring Boot itself does not create networking concepts from scratch.
This means frameworks simplify development, but the underlying server concepts still come from Java.
A concise interview answer is
Yes, a server can be created in pure Java without any framework. Java provides built-in APIs such as ServerSocket for TCP communication and HttpServer for HTTP services. Frameworks like Spring Boot simplify server development by providing additional features such as dependency injection, REST support, and configuration management, but they are not required to create a server.
Last updated: 11 November 2026
Previous question: What is the Java Memory Model, and how is it related to threads?
Next question: What is the transient keyword in Java?