Connecting your Java Code to Postgresql installation via terminal in Linux

I’ve always hated using IDE’s, QtCreator being an exception, but I know that I might eventually have to end up using one.
For simple Java Codes however, Vim – my preferred text editor, I’m yet to master it btw – should be more than enough. And fair enough, it does do it’s job perfectly. The trouble comes when one tries to compile the Java program while providing the JDBC library while running the Java Class.
The key here, is to provide it as a “classpath” the option with the “java” command, when you intent to run the class file after compilation. You know the drill, compile followed by run. Here’s what you do.


$ javac yourFile.java
$ java -cp :path/to/your/jdbc/jar yourFile

A screenshot that might help
A screenshot that might help
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s