简体   繁体   中英

Can't figure out why Mongo Database app won't work correctly after creating a jar executable

I created a java GUI application using java.awt. The basic idea off the app is to query a mongo database using the mongo-java driver.

When running the code from the command prompt, the GUI opens up and it can interact with the initialized mongod server just fine with no problem. However, when I create a jar executable with the same class, the GUI opens up fine, yet none of the server interactions seem to occur.

For instance, when running the non-jar version, the mongod server running in the background displays something along the lines of: Sat Dec 14 09:14:20.347 [initandlisten] connection accepted from 127.0.0.1:XXXX #5 (1 connection now open) , yet when running the jar version (without making any changes to the source code at all, literally the same exact .java and .class files), I don't see any of the conection statuses on the server.


I doubt you need me to insert all my code into this post, but here are the details that I think are most relevant to my issue. Let me know if you need any other details.

when creating my jar I used the command:

jar cvfm MongoDBGUI.jar manifest.txt *.class

manifest.txt has the line:

Main-Class: MongoDBGUI

*MongoDBGUI being the class with the main function

My crystal ball says that you've been swallowing exceptions in your code, so when something goes wrong, you have no logging to tell you what the error was.

My tarot cards tell me that you don't have the driver packaged inside your jar, so the driver isn't found. But my ouija board claims that you do have the driver inside the jar, it's just not configured properly in the classpath in MANIFEST.MF.

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