简体   繁体   中英

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. 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. 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.

I'm new to Derby and I'm confused by this, any suggestions?

上面的答案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. Basicly, try following their tutorial here:

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.

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. It's the option called "Package required libraries into generated jar". Maybe Netbeans lets you do that now too, via some export function or something similar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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