0

I have developed a small Java application using Eclipse. I created an executable jar from it using one jar. I want to be able to execute this application on both a pc or a mac.

The application executes perfectly on a pc but on a mac, I have this error message:

Error message

It seems there is some problem with one-jar but why is it working with a pc but not with a mac? Do you have any idea about the problem?

I'm using Java 8 on both the pc and the mac.

Thank you

  • On a first glance I cannot really see what promise one-jar has over build tools like Gradle or Maven. Especially as the last version is already like 3 years old and not under development any more. Apart from that I guess finding the error without further information is somewhat like guessing. For me on a brief look seems to be something like a file not found (pathing can cause some severe issues on different OS!). But that's as I said more of a guess than a fixed answer. – Marco N. Oct 28 '16 at 19:01
  • About why I used one jar rather than Gradle or Maven: This is a really a small application with only a SqLite database and some pictures files. I wanted a very quick and simple way to get an executable jar. – andré marquis Oct 28 '16 at 20:05
  • I am just asking because it would be good to know if it is an issue with the program you developed or whether there is an issue within the build tool you used (as @greg-449 also points out). And yeah, Eclipse and IntelliJ (only used the two so far) both provide some tools to build jars. However, if I recall correctly these tools are sometimes quite nasty to use (setting up class- and library paths and stuff). – Marco N. Oct 28 '16 at 20:21
  • 1
    It looks like the onejar code is expecting some JVM internals to work in a specific way - and this is not working on macOS. This is likely to be difficult to fix. Since you are using Eclipse you could try the Eclipse Export 'Java > Runnable Jar File' which does something similar. – greg-449 Oct 28 '16 at 20:21
  • I'm using path to get some image file. Like these liene of code : – andré marquis Oct 28 '16 at 21:36
  • I'm using paths to get some image files. Like these one: /res/ui/icon.png and also /res/ui/splashScreen.png. Do you think those paths are problematic on a Mac? Also, I forgot to mention that I was using the Fat Jar plugin to get the SqLite database within the jar. But I build a jar using Export/Runnable Jar file... and it worked on a PC. I will be able to tell you if it works also on a Mac this Monday... – andré marquis Oct 28 '16 at 21:42
  • Well for paths I tend to use `File.separator` for quite some time. I encountered a very similar issue as yours: I programmed my app on windows and also used normal `/` to navigate through folders. Interestingly that also worked on a Mac but failed totally when used on a Linux system. So while I cannot guarantee you that this is the issue (or something done wrong by one jar), I would tend to be careful with the use of paths. It is quite easy to do something wrong there. – Marco N. Oct 28 '16 at 23:00
  • In my case, File.separator returns \\, so the path /res/ui/icon.png becomes \\res\\ui\\icon.png and this path is invalid... – andré marquis Oct 29 '16 at 02:30
  • Hello! It worked!!! Just using Export/Runnable Jar file worked. The application run fine on a Mac! It seems one jar is incompatible with Mac OSX. Thank you! – andré marquis Oct 31 '16 at 12:57

0 Answers0