I have a Java protect with the c3p0 JAR. Compiling my project in eclipse works. No errors or something. But when i try to run my application it says the following:
java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/DataSources
Do i need to give the jar file the other jarfile from c3p0? Or could i link them when launging the application?
Note: I’ve understood your problem to be when running outside Eclipse.
The standard Java classloader responsible for loading your classes does not understand jar-files inside jar-files, so you need to do something else:
The
File->Export->Runnable jaroption in Eclipse can do all three based on what you choose. Pick the one best suited to how you will get the classes to the final users.Personally I like the “jars next to the generated jar” as it is the closest to what is supported out of the box by Java, while keeping the original jar files. The simplest is most likely to merge all classes, but when you get more advanced you will find that it has some disadvantages – at this point you will most likely not encounter them.