title: Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.NullPointerException
body: <p>I am using config.properties file in order to set port. After running I am facing an error:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ExceptionInInitializerError</p>
    
    <p>Caused by: java.lang.NullPointerException at</p>
    
    <p>java.util.Properties$LineReader.readLine(Properties.java:434) at</p>
    
    <p>java.util.Properties.load0(Properties.java:353) at</p>
    
    <p>java.util.Properties.load(Properties.java:341) at</p>
    
    <p>HttpServer.setPort(HttpServer.java:83) at</p>
    
    <p>HttpServer.(HttpServer.java:26)</p>
  </blockquote>
  
  <p>The main class:</p>
  
  <pre><code>public class HttpServer {
  
      static final boolean SSL = System.getProperty("ssl") != null;
      static final int PORT = Integer.parseInt(System.getProperty("port", SSL ? "8443" : setPort()));
  
      public static void main(String[] args) {
          HttpServer httpServer = new HttpServer();
          httpServer.start();
      }
  
      public void start(){}
  
      public static String setPort() {
          String port = "";
          Properties properties = new Properties();
          try {
              properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("src/main/config.properties"));
              port = properties.getProperty("server.port");
          } catch (IOException e) {
              e.printStackTrace();
          }
          return port;
      }
  }
  </code></pre>
  
  <p>I am not able to understand what is the error...</p>