1

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.

Yu-Chih Tung
  • 81
  • 1
  • 9
  • Sorry, I don't want to bother you but as far as I know, AppBundler isn't actively maintained. You can use PackR or JNDT instead. I used the former for a few months and I have used the latter for a long time. I advise you to add some log messages into your Java program. You can use "open -a " in command line to get some information. Look at this answer http://stackoverflow.com/a/1583766/458157 – gouessej Jan 05 '16 at 15:51
  • Hi @gouessej, thanks for your reply. I will look at your suggestions. I also have the concern of the maintenance, but it seems the only method supported by official java community. – Yu-Chih Tung Jan 06 '16 at 07:56
  • What do you mean by "official"? AppBundler hasn't been updated for about 3 years as you can see here: https://java.net/projects/appbundler/sources/svn/show – gouessej Jan 06 '16 at 11:37
  • The documentation of JNDT OS X target is here: http://tuer.sourceforge.net/en/documentation/#create-os-x-app-bundle – gouessej Jan 07 '16 at 16:26

1 Answers1

0

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.

JimmyJames
  • 1,356
  • 1
  • 12
  • 24
  • Hi, it works but not the answer I am looking for because my app crashes only when I "execute the app (bundled jar)". – Yu-Chih Tung Jan 04 '16 at 22:42
  • So you didn't get any more output? You can try executing the main class explicitly. I will update the answer with an example. – JimmyJames Jan 05 '16 at 16:27
  • Yes. It will get output but it does not help to debug the app bundle. For example, I am facing a issue caused by "lib/resource path" which only happens when I click the app bundle (w/o output) but behaves ok when I do java -jar my.jar (w/ output). – Yu-Chih Tung Jan 06 '16 at 08:02
  • It does help because if you can run it that way, it tells me that the manifest is wrong. Extract the contents of the jar with the jar command or any zip extractor. You should see a META-INF folder containing a file named MANFEST.MF. That file controls what happens when you 'execute' a jar. – JimmyJames Jan 06 '16 at 14:46
  • @Yu-ChihTung Maybe you can look at my working app file, compare it to yours: http://tuer.sourceforge.net/en/play/ – gouessej Jan 07 '16 at 16:28
  • Sorry, SourceForge is known to be a distributor of greyware. I've provided the basic information you need. If you are stuck I suggest reading more about executable jars and how they work. – JimmyJames Jan 07 '16 at 16:34