I use TopLink bundled inside Glassfish. Compiling and running java persistence application is easy, even when done from command line, as you can see from the previous post.
At compile time, I only have
toplink-essentials-agent.jar in classpath. This jar only contains a java agent class:
oracle/toplink/essentials/internal/ejb/cmp3/JavaSECMPInitializerAgent.clasBut its META-INF/MANIFEST.MF contains a
Class-Path entry , in addition to a
Premain-Class: oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInSo the class loader will follow this reference and load
<other entries omitted here>
toplink-essentials.jarin the same directory.
toplink-essentials.jarcontains all the Java Persistence API and implementation classes.
At runtime, I don't even have any toplink jar in classpath. Because we use
-javaagent:toplink-essentials-agent.jar, and any agent jars are automatically appended to the classpath. I wrote this post on -javaagent: option. So runtime classpath only needs to include application classes and jdbc driver jar.
In NetBeans 5.5, I found I do need to include both toplink-essentials-agent.jar and toplink-essentials.jar in project library. Otherwise, NetBeans can't find JPA classes.