title: error: java.lang.ClassNotFoundException: org.postgresql.Driver
body: <p>I'm just trying to connect to postgres (13.0.1) from java (11.0.8) on Debian 10 and get the error below:</p>
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
  public class cli_test {
      public static void main(String[] args) {
      
          try {
              Connection connection = null;
              Class.forName(&quot;org.postgresql.Driver&quot;);
              
              connection = DriverManager.getConnection(&quot;jdbc:postgresql://localhost:5432/myproj&quot;, &quot;postgres&quot;, &quot;&lt;pwd&gt;&quot;);
              
              System.out.println(&quot;Connection established successfully&quot;);
          } catch (Exception e) {
              System.out.print(&quot;error: \n&quot; + e.toString() + &quot;\n&quot; + e.getMessage());
          }
      }
  }
  </code></pre>
  <p>I run these commands:</p>
  <pre><code>CLASSPATH=/usr/lib/jvm/java-11-openjdk-amd64/lib/postgresql-42.2.18.jar
  javac -verbose cli_test.java
  java cli_test
  </code></pre>
  <p>I have verified that the jar file exists in that location and is set to 755 permissions.</p>
  <p>I get this error:</p>
  <pre><code>java.lang.ClassNotFoundException: org.postgresql.Driver
  </code></pre>
  <p>I have spent hours searching online and found many others with this problem. No other solutions I found have fixed it. I'm trying to do this without a java ide, just a text editor.</p>