Nils
Nils

Reputation: 13767

JPA and database in a single jar

I created an app which uses JPA and MySQL. Now I like to create simple desktop application out of it (eg a simple jar would be best). Two questions:

Upvotes: 3

Views: 944

Answers (2)

BalusC
BalusC

Reputation: 1108732

  • What's the easiest way to get a project including all jars it depends on out of eclipse in a simple jar?

Create a Java Project, write code, rightclick project, choose Export > Runnable JAR file and finally choose from the Library handling options.

alt text

  • Can I use a database like sqlite or derby which requires no installation (eg can be included in the jar) for JPA?

Yes, you can do that. Just include and specify the suitable JDBC driver.

Upvotes: 4

Carl Smotricz
Carl Smotricz

Reputation: 67760

Yes, there are a number of "embeddable" databases that require no separate server process. That solves part of the problem.

Another part of the problem is that all your 3rd party code (the JPA engine, the database and maybe more) sits in yet other jars. If you really truly want just a single jar, you'll have to mung all those jars together into one. There are some programs that accomplish this, I seem to remember the name "bigjar" but Google isn't turning up any good leads for it. However, you can easily do the equivalent yourself using just ant. There's a big discussion (with sample code) in this Sun forum thread.

Upvotes: 0

Related Questions