Running a java program in linux terminal with -class path
- by Arya
Hello
I've been trying for an hour to run the following program with a the postgresql classpath
class Test{
public static void main(String[] args){
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.err.println("Couldn't find Postgresql driver class!");
}
}
}
The program compiled fine with the javac command, but I'm having a hard time running it with the postgresql classpath. I have "postgresql-9.0-801.jdbc4.jar" in the same directory as the file and I tried the following, but non of them worked
java -classpath ./postgresql-9.0-801.jdbc4.jar Test
java -classpath postgresql-9.0-801.jdbc4.jar Test
java -classpath "postgresql-9.0-801.jdbc4.jar" Test
What am I doing wrong?
Regards!