Create Mac .dmg file from Java

4.4k views Asked by At

I would like to create a DMG file from Java.

The reason why it needs to be Java is twofold: It must be part of our build farm (which currently runs on a non Mac OS X platform) and our build uses Maven (which pretty much means Java).

As far as I can a tell inside a DMG file can be an ISO9660 file system. I can create such beast using this but then I still need the part where the whole thing is wrapped in the DMG format. Something like iso2dmg tool except I need it for Java.

When answering: Forget about the Maven part. If you have a Java solution then I can figure out the Maven stuff myself. (e.g. creating my own little Maven plugin if I need to).

2

There are 2 answers

0
Mario Estrella On

The appbundle-maven-plugin works on both Linux and Mac to generate an app bundle(YourProgram.app) and then a .dmg. Make sure you have genisoimage as that's what it uses in Linux to create the dmg.

<plugin>
    <groupId>sh.tak.appbundler</groupId>
    <artifactId>appbundle-maven-plugin</artifactId>
    <version>1.2.0</version>
</plugin>

https://github.com/federkasten/appbundle-maven-plugin

2
Marco On

You can use the javapackager tool.

A simple, well explained, step by step tutorial on how to create a DMG from java is here: http://centerkey.com/mac/java/