简体   繁体   English

Java DB Derby和Netbeans 7.1构建问题

[英]Java DB Derby and Netbeans 7.1 Build Problems

My application accesses a Derby Database and I have added the Derby.jar to the libraries in the project. 我的应用程序访问一个Derby数据库,并且已将Derby.jar添加到项目中的库中。 It runs fine when compiled and runs perfectly inside the Netbeans environment but once I Build the project, only my application.jar file is in the dist folder. 它在编译时运行良好,并且可以在Netbeans环境中完美运行,但是一旦我构建了项目,只有我的application.jar文件位于dist文件夹中。 The program will still run but once I try doing anything with the database it hangs. 该程序仍将运行,但是一旦我尝试对数据库执行任何操作,它将挂起。

I tried adding the lib folder containing Derby.jar to the home directory of the application.jar but I still get the same problem. 我尝试将包含Derby.jar的lib文件夹添加到application.jar的主目录中,但是仍然遇到相同的问题。

I'm new to Derby and I'm confused by this, any suggestions? 我是Derby的新手,对此感到困惑,有什么建议吗?

上面的答案1不能解决以下事实:您需要先连接到IDE的“服务”选项卡中的数据库,然后才能运行应用程序,而在IDE外部运行应用程序时,这是不可能的。

This is because you don't also add the project external jar dependencies (such as Derby's jar) to the classpath of your project's executable jar. 这是因为您还没有将项目外部jar依赖项(例如Derby的jar)添加到项目的可执行jar的类路径中。 Basicly, try following their tutorial here: 基本上,请尝试在此处遵循其教程:

http://netbeans.org/kb/articles/javase-deploy.html#Exercise_1 http://netbeans.org/kb/articles/javase-deploy.html#Exercise_1

the chapter entitled "Running the Application Outside of the IDE" and the one after that. 标题为“在IDE外部运行应用程序”的一章及其后的章节。

I haven't used Netbeans in a long while so I don't know if they added this functionality to it now, but with Eclipse you can also make a "fat" executable jar, where all the external jars are packed inside that executable jar, and Eclipse adds a special classloader which makes all this work. 我已经很长时间没有使用Netbeans了,所以我不知道他们是否现在已经向其中添加了此功能,但是使用Eclipse,您还可以制作一个“胖”可执行jar,其中所有外部jar都打包在该可执行jar中,并且Eclipse添加了一个特殊的类加载器,该类加载器可以完成所有这些工作。 It's the option called "Package required libraries into generated jar". 该选项称为“将所需的库打包到生成的jar中”。 Maybe Netbeans lets you do that now too, via some export function or something similar. 也许Netbeans现在也可以通过某些导出功能或类似方法使您做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM