Table of Contents • • • • • • • • In this article I’ll show how to build a application from a Java Jar file. I tested this with 1.8 on macOS 10.12.5 (Sierra) on June 29, 2017. Three assumptions in this process are: • You have a single Jar file you can already run with the java -jar command • You aren’t concerned about implementing macOS-specific features, like enabling the Preferences and Quit menu items, or implementing Mac-specific keystrokes in your app • I assume your application is a Java Swing or JavaFX GUI app (I understand that those first two items can be big assumptions. They created an “AppBundler” Jar file that can be used with Ant to build a Mac application, and that’s what I use in this process. Update: While you can still use the AppBundler described in this article — and in some ways it’s a more obvious approach to building a Mac/Java application — Oracle now recommends building Mac/Java applications with their javapackager tool. I write about it in my. Requirements The requirements for building a macOS/Java application with this specific build process are: • You’ll need the Java SDK installed. I tested this with Java 1.8 on macOS 10.12.5. • You’ll need Ant. I tested this with Ant 1.10.1, which I installed with. • Make sure JAVA_HOME is set. (You may get an error if it isn’t set.) • Your Java application needs to be in one Jar file. This distribution includes a hello.jar file to show how things work. • The application probably needs a META-INF/MANIFEST.MF file in that Jar file. (I didn’t test it without one.) As mentioned earlier, the biggest assumption is that your application completely exists in one Jar file such that you can run it with the java -jar command. If you have that, this build process should work; if you don’t have that, you’ll need a more-complicated build process. By using our site, you acknowledge that you have read and understand our Cookie Policy. I have build a JAR file, I have a tool that converts this JAR file to.pkg file which can be distributed on MAC OS. Where is Java Installed on Mac OS X? But you can open HFSExplorer, read a Mac-formatted drive, and copy the files to your Windows PC without paying a dime. It can also mount Mac.dmg disk images to get at the files inside them. This application’s read-only nature isn’t necessarily a bad thing. Building your application To build your application: • Clone. • cd into that directory. • Copy your Jar file into the current directory. • Change the variables at the top of the build.xml file to match your application. • Eventually you’ll want to create your own icon file as a macOS icns file, but you can start with my world.icns file until you create your own. • In the macOS Terminal (or similar app), type ant to build the application. ![]() • Assuming you named your application “HelloWorld”, type open release/HelloWorld.app to run your application. If all goes well, your application will be shown in a few moments. (I assume your application is a Java Swing or JavaFX GUI app.) You can then type type open release to open the folder that contains your app, and then you can use the Mac Finder to copy your app to your desktop (or anywhere else). Formatting hardrive for windows and mac. Note 1: Font smoothing Java applications built like this seem to have non-smooth fonts on macOS. ![]() This is usually immediately apparent in the title bar of your application. To get a smooth font with your application, follow this build process: • Edit the _addHiResKeyToPlistFile.sh file • Set the APP_NAME variable in that file to the same app_name you use in the build.xml file • Run the script named _build.sh to build your application.
0 Comments
Leave a Reply. |