Java swing ubuntu 应用程序不加载 sqlite

标签 java swing sqlite ubuntu

我在 Windows 中制作了一个使用 sqlite 数据库的 java swing 应用程序。我将我的应用程序移至 Ubunty Linux 上,下载了最新的 jdk 和 jre。当我从 Netbeans 运行应用程序时,一切都很好,但是当我从 dist 文件夹运行它时(右键单击 jar 文件夹并选择使用 jre7 运行)应用程序启动,但未加载 sqlite 数据库中的数据。首先,我认为这是关于在 Ubunty 内部授予我的 sqlite 数据库读取和写入数据的权限(右键单击 sqlite 数据库文件夹,然后单击 Access 选项集以读取和写入并设置 ,并使文件能够作为程序) 。 我该怎么做才能使我的 sqlite 数据库能够在 Netbeans Ide 之外加载。

最佳答案

Show your error message – AlexR 14 mins ago There is no error message , now I tried to run my app from console and it works ok but when I run in by mouse click it does not load sqlite database , this is an Ubunty stuff. – Jovo Krneta 11 mins ago

好的,这解释了一些事情。

当您单击 jar 文件时,您正在使用命令行运行应用程序,例如:

java -jar yourjar.jar

JVM 打开您的 MANIFEST.MF,确定主类和类路径并运行您的应用程序。我相信在您的情况下,类路径未被正确识别。

这里是解释如何定义它的文档: https://blogs.oracle.com/olaf/entry/jdev_including_a_classpath_in

Class-Path

The Class-Path tag is useful for specifying the list of the libraries application needs to successfully run. You can specify the class path like any other but use the blank character (' ') as the path separator. Ie. no colon (':')or semicolon (';') as for the Un*x/Linux or Win environments, respectively. To specify the Class-Path tag in your MANIFEST.MF you need to include a line like the following: Class-Path: lib/ojdbc14.jar lib/log4j.jar

我相信,由于您使用 IDE 在 Windows 上创建了可执行 jar,因此您的类路径是使用 Windows 特定分隔符 ; 定义的。检查这一事实,如果正确,请将其替换为与平台无关的空格字符 ""

例如,如果您的类路径定义为 Class-Path: one.jar;two.jar 将其替换为 Class-Path: one.jar Two.jar

如果情况并非如此,请无论如何检查路径。驱动程序 jar 的路径对于 ubuntu 是否无效?您可能使用反斜杠或绝对路径吗?

检查所有这些事情。我相信你很快就会发现问题。 99%是你的问题出在类路径上。

关于Java swing ubuntu 应用程序不加载 sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18558689/

相关文章:

java - 获取图像模糊的百分比

java - 在 ExecutorService 中等待 Runnable 任务完成的有效方法

java - 从 JTable 拖放到 JLayeredPane

java - 当我从命令行运行时,JLabel 不会改变

java - 如何在java中解密(包括我的代码片段)

java - 生成给定字符串的所有排列

java - 无法将 imageicon 设置为 JLabel,始终为 null

java - 为大量 JTextField 提供复制/粘贴菜单

swift - 如何使用 IN 条件访问 SQLite.swift 中的 FTS 表

sqlite - 使用 RAISE 创建触发器