I have a BIG problem with my ANT buildfile. I'm trying to run a simple Test to connect to my app's database, but after it succesfully COMPILES and JARS itself, when it gets to EXECUTE I get the following message:
[java] org.dotcom.contab.proceso.DAOException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver [java] at org.dotcom.contab.proceso.impl.MySQLDAOFactory.<init>(Unknown Source) [java] at org.dotcom.contab.proceso.DAOFactory.getDAOFactory(Unknown Source) [java] at org.dotcom.contab.salida.Main.main(Unknown Source) [java] Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) [java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) [java] at java.lang.Class.forName0(Native Method) [java] at java.lang.Class.forName(Class.java:164) [java] at org.dotcom.contab.proceso.impl.MySQLDAOFactory.loadDriver(Unknown Source)
I know I probably have a problem with the CLASSPATH, since I'm running the app directly from the jar archive: here's the code:
I'm really really stuck, I've tried a bunch of things and I don't know what to do anymore. I read somewhere that when running a program from the jar it ignores user classpath settings, is it true??? I NEED to run it from the jar since it's one of the projects requirements...
I notice that you seem to be putting third party jars into your jar file. Those other jars will *not* automatically be on the classpath!
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
posted 13 years ago
Yeah, I'm aware of that, but how do I PUT them into the classpath???
I'd be useless without Head First books...
posted 13 years ago
After fighting with the CLASSPATH for more than 24 hours, I fixed it
I had to put the JAR File next to the distribution. And set the Manifest's Class-Path to the JAR File. It finally worked. Thanks!