All I'm trying to do is convert a simple java program into a macOSX .app file so I can distribute it as a simple executable file.
I've read all over the place and everyone says the same things:
Use Jar Bundler - All the tutorials seem to be out of date, and it doesn't work. When I run: java -jar jarbundler-2.0.0.jar
The console returns "no main manifest attribute in jarbundler-2.0.0.jar"
If I'm right, this would be a fail on whoever packaged the jar file right? But I've tried downloading it from other websites and other versions, but I get the same thing.
They say you can just create the directories and files yourself and then rename your folder to .app and then run a command on it or something but this is complicated since I don't know exactly how to create an info.plist file...if you want to do it this way, the best website I've found so far is this one: Java Deployment Options for OSX
I've compiled my code into a .jar file, I have an icon and everything, all I need to do is package it somehow into a .app file.
Thanks for the help in advance!
EDIT: I got it! After 7 or 8 hours of searching and reading it works. Since I'm new to this, I'm going to post everything I learned to save others that run into the same problem from going through the pain. I gave up on the do it yourself method and went back to JarBundler. If anyone else is reading this and they don't know anything about ANT, here's what I did: Download JarBundler, I got mine from here: Mac OS X JarBundler ANT Task and follow the instructions there.
When you download it, put the jarbundler-2.2.0.jar file here:
/usr/share/ant/lib
you might have to run a command to move it, something like:
sudo mv jarbundler-2.2.0.jar ~/../../usr/share/ant/lib/jarbundler-2.2.0.jar
like I said, I'm still learning, but this worked for me.
Make sure you moved the right jarbundler, this is where I ran into problems, I moved the entire folder, rather than the inner .jar file, so make sure you move the .jar that's inside the folder zip you downloaded, not the whole thing, otherwise when you go to build it, you'll get an error saying something like error: taskdef class net.sourceforge.jarbundler.JarBundler could not be found.
Then you need to compile your code into a .jar file (there are two types, one is like a .zip and the other is an executable) You want a normal JAR file, NOT executable, so to do that you first need to compile your code to get .class files, then open a command prompt and follow the instructions here: Create a Jar File The command will look something like this:
jar cf myName.jar *.class
Once you have your jar file, you need to create a .xml file in the same folder and needs to be called build.xml. Edit it with a text editor. Follow the instructions on the link above to create it. It will look something like this:
//build.xml
<project name="MyProject">
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler" />
<target name="bundle">
<jarbundler dir="release"
name="Apollo's Image Editor"
mainclass="ImageEditorGUI"
jar="ApolloIE.jar"
icon="Aperture.icns" />
</target>
</project>
From there (I'm using a Macbook Pro by the way) all you have to do is run a command line from that folder:
ant bundle
and it should create a .app file in a folder called release. So to summarize: all you need is your .jar file and build.xml file in the same folder, and then run the command: ant bundle (or whatever you named your target in the build.xml file, I named it bundle)
Good luck, hope this helps anyone out there.
If anyone is wondering, I took the Info.plist that was generated by the JarBundler and put it into the directory I was making and it worked! So that was the problem, I just didn't know how to format it right... here it is: Info.plist
On Mac OS X, an application bundle is a directory that has a name ending in .app
and that contains the resources used by the application. This game is an example that constructs the bundle in situ using an ant
build script. Additional references are cited here.