Question: how to create database in postgresql using java?
Answer: Make sure you have Java and Java Compiler (javac) installed on your server. ... 
Download the latest version of PostgreSQL JDBC driver from the PostgreSQL website: https://jdbc.postgresql.org/download.html.
Set the correct CLASSPATH for the PostgreSQL JDBC driver and classpath files, for example: