I just compiled a java program in the console. Now I want to run it. I needs jdbc driver for postgresql and mysql. Therefore I need to include the corresponding jars.
I did the follwing
java -Xmx512m -cp ".;/path/to/sql/jars" main.Main rc
When doing so I get the follwoing error:
Exception in thread "main" java.lang.NoClassDefFoundError: main/Main
Caused by: java.lang.ClassNotFoundException: main.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: main.Main. Program will exit.
When ignoring the classpath option like this
java -Xmx512m main.Main rc
I get the follwing error
java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at database.PostgresQL.getConnection(Unknown Source)
at database.PostgresQL.loadIndexFromDatabase(Unknown Source)
at main.Main.readDataFromDatabase(Unknown Source)
at main.Main.main(Unknown Source)
So, the program can be run correctly. My question: How to I tell the program to lookup the jars correctly in the console?