Quick googling reveals the query:
select version();
Run it through JDBC, you have java anyway.
As for running the the postgres server itself, I think the old way Runtime.exec/ProcessBuilder will do the job. You may want to create some kind of script above it but that the way it should work, I guess, there is no other way.
If you're running on linux machine, maybe you should install the server as a service and run it respectively, but from the point view of Java (if you really want to run it from java) its still an invocation of external process.
Hope this helps