当前位置: 动力学知识库 > 问答 > 编程问答 >

osx - Get Java system output after the jar file is bundled (by AppBundler in MAC)

问题描述:

I am writing a java program and try to ship it as a MAC app. I have successfully built a simple testing jar file (for test only) and package it by AppBundler. However, when I try to package my real program, the app just crashes (disappear after it is executed) without any error message. I am wondering if there is any way to get the error message dumped by my jar file so I can understand what is the issue to solve.

BTW, I execute the app(jar bundled) by just clicking its icon. There is nothing shown but getting a useless message, "unknown exit code 1", in my Console.

Could anyone let me know how I can get java output back when I execute it as a bundled app?

EDIT: my app works when I manually find the jar file (ex: XXX.app/Contents/Java/XXX.jar) inside app bundle and do "java -jar XXX.jar" but it crashes when I execute the app directly. I suspect the problem is caused by referencing the wrong resource directory but there is no java error message, making the debug nearly impossible.

网友答案:

You can run your program with Java on the command line like so:

java -jar yourjar.jar

If you want to try running your main class explicitly, do this:

java -cp yourjar.jar your.package.MainClass

If it fails with the second command, the classes were not packaged in the jar properly. If it works, there's something wrong with the manifest file.

分享给朋友:
您可能感兴趣的文章:
随机阅读: