如何将H2数据库嵌入到客户端的jar文件中? [英] How to embed H2 database into jar file delivered to the client?

查看:266
本文介绍了如何将H2数据库嵌入到客户端的jar文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在嵌入式模式中使用H2数据库作为桌面应用程序。当我将应用程序压缩到jar文件中时,数据库文件被省略。所以,当我运行MyApplication.jar没有什么工作。什么是嵌入/ include /连接h2.jar文件与MyApplication.jar的正确方法?

I use H2 database for a desktop application in embedded mode. When I compress the application into jar file the database file is omitted. So, when I run MyApplication.jar nothing works. What is the correct way to embed/include/connect h2.jar file with MyApplication.jar? Or maybe there is another way to deliver database and application in the bundle?

推荐答案

一个常见的方案是把 h2.jar 在相对于您的应用程序的 lib 目录中,并包括 Class-Path

One common scheme is to put h2.jar in a lib directory relative to your application and include a Class-Path entry in your JAR's manifest with an entry for it:

Class-Path: lib/h2.jar lib/…

附录:这小项目包括指向 JAR规范和用于原位检查清单的便利实用程序。

Addendum: This small project includes a link to the JAR specification and a handy utility for examining the manifest in situ.

这篇关于如何将H2数据库嵌入到客户端的jar文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆