I'm trying to run the tutorial example as given in the tutorial on ObjectDB's net pages. I am using NetBeans IDE 13 with Java 17.0.2 on Windows 11and with ant. My ObjectDB is version 2.8.7.
Q 1)
The tutorial is supposed to run embedded. If the file given does not exist, it should be created. Instead I get the error "No Persistence provider for EntityManager named objectdb:punkter.odb" that many have reported. Answers I find invariably focus on the "persistence.xml" and where it should be stored, contents etc. Since I am running the program in embedded mode, this file should not be necessary. Can anyone see the problem? Could the problem be the javax.persistance version?
package tutorial; import javax.persistence.*; import java.util.*; public class Main { public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb:punkter.odb"); EntityManager em = emf.createEntityManager(); …. the code continues as in the tutorial…
(I should mention that I have tried running NetBeans in admin mode, and I have tried creating an empty "punkter.odb" file in the map holding the java-files as well as the map containing the class-files. All in case NetBeans have problem creating the file.)
Q 2)
Several sources are adamant that the program class should be called "Main". I fail to see the significance of that. Can you please explain if this is really necessary and if so, why?
Q 3)
I have tried several versions of "javax.persistence". When I use "javax.persistence_1.99.0.jar" I get an error using TypedQuery. I have therefore tried "javax.persistence-2.2.0-release.jar". Then TypedQuery is recognized but the "No Persistence provider" error persist. Can you tell me what version of javax.persistence I should use and where I can find it?