Q: Socket programing Java ,java.net.BindException: Address already in use: JVM_Bind I created server and client classes to practice socket programming and when I try to run server class I get this error message. my java version is 8 and I'm using IntelliJ IDEA ultimate
 java.net.BindException: Address already in use: JVM_Bind
        at java.net.DualStackPlainSocketImpl.bind0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
        at java.net.ServerSocket.bind(ServerSocket.java:390)
        at java.net.ServerSocket.<init>(ServerSocket.java:252)
        at java.net.ServerSocket.<init>(ServerSocket.java:143)
        at simple_tcp.Server.<init>(Server.java:10)
        at simple_tcp.Server.main(Server.java:33)
    Class transformation time: 0.0110188s for 136 classes or 8.102058823529413E-5s per class

my Server.java class is
package simple_tcp;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

    public Server() throws IOException {
        ServerSocket server_socket=new ServerSocket(2020);//opening a new port
        System.out.println("port 2020 has been opened!");

        Socket socket=server_socket.accept();
        System.out.println("Client "+socket.getInetAddress()+" has connected");

        /////////////////////////////////////////

        BufferedReader in_socket=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out_socket=new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);


        out_socket.println("Welcome");//send "welcome" to client
        String message=in_socket.readLine();
        System.out.println("Client says "+message);

        /////close socket
        socket.close();
        System.out.println("Socket is closed");
    }

    public static void main(String[] args) {
        try {
            new Server();


        }
        catch (Exception e){
            e.printStackTrace();

        }
    }
}

and Client.java class is
package simple_tcp;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

public class Client {

    public Client() throws  Exception{
        Socket socket=new Socket("localhost",2020);
        System.out.println("Successfull conection to server");
        BufferedReader in_socket=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out_socket=new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);

        String message=in_socket.readLine();
        System.out.println("server says "+message);
        out_socket.println("Thanks");
      socket.close();
        System.out.println("socket closed");

    }

    public static void main(String[] args) {
        try {
            new Client();
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}

and I get the same error trying to run the Client.java class also
can anyone help me to fix this error
