These documentation pages are no longer current. They remain available for archival purposes. Please visit
https://docs.oracle.com/javase
for the most up-to-date documentation.
- Make A Java Based App Work On Mac Computer
- Make A Java Based App Work On Mac Os
- Make A Java Based App Work On Macbook
- Run Java On Mac
A game studio in your browser, with everything you need built in. Make games without programming - the Flowlab game creator has the tools you need, all included and easy to learn. Everything is stored online, so sharing your games is simple. Publish and sell your games on the Apple, Google and Amazon App Stores! Download Java for OS X directly from Oracle. Get the latest version If an app or webpage you want to use asks you to install Java software, you can download the current version of Java for OS X directly from Oracle's website.
This page shows you, step by step, how to convert a simple Java application to a version you can distribute on a Mac. To follow along, download the ButtonDemo (.zip) example from the Java Tutorial. This example was created using NetBeans which uses the Ant utility. You can run all necessary tools and make all necessary edits from the command line, without launching NetBeans. The Ant tool is required.
You have created a Java application and want to bundle it for deployment. This requires the following steps:
Create a JAR File
This step creates the ButtonDemo.jar file.
Execute ant jar in the high-level project directory to create the dist/ButtonDemo.jar file. This jar file is used to create the .app package.
Bundle the JAR File into an App Package
To create the ButtonDemo.app package, use the appbundler tool. The appbundler is not shipped with the 7u6 version of the Oracle JDK for the Mac. You can download it from the Java Application Bundler project on java.net. There is also AppBundler Documentation available.
As of this writing, the most recent version is appbundler-1.0.jar, which is used by this document. Download the latest version available and substitute the file name accordingly.
- Install the appbundler-1.0.jar file. In this case, create a lib directory in the high-level project directory and add the appbundler-1.0.jar file.
- Modify the build.xml file in the high-level project directory as follows. (The added code is shown in bold.)
- Invoke the appbundler by typing ant bundle-buttonDemo from the high-level project directory. This creates the ButtonDemo.app package in the dist directory.
- You should now be able to launch the application by double clicking ButtonDemo.app in the Finder, or by typing open ButtonDemo.app at the command line.
Bundle the JRE with the App Package
In order to distribute a Java application, you want to avoid dependencies on third party software. Your app package should include the Java Runtime Environment, or JRE. In fact, the Apple Store requires the use of an embedded JRE as a prerequisite for Mac App Store distribution. The runtime sub-element of the <bundleapp> task specifies the root of the JRE that will be included in the app package.
In this example, the location of the JRE is defined using the JAVA_HOME environment variable. However, you might choose to bundle a JRE that is not the same as the one you are using for development. For example you might be developing on 7u6, but you need to bundle the app with 7u4. You will define runtime accordingly.
Since this example defines the runtime sub-element using JAVA_HOME, make sure it is configured correctly for your environment. For example, in your .bashrc file, define JAVA_HOME as follows:
Use the following steps to modify the build.xml file at the top of the project directory:
- Specify an environment property, named env:
- In the target that creates the bundle, specify the location of the JRE on your system, using the env property:
The resulting build.xml file should look like the following. (The new lines are shown in bold.)
Create a fresh version of ButtonDemo.app, using the ant bundle-buttonDemo command. The resulting version includes the JRE in the app package. You can confirm this by examining the Contents/PlugIns directory inside of the app package.
Sign the App
The Gatekeeper feature, introduced in Mountain Lion (OS X 10.8), allows users to set the level of security for downloaded applications. By default, Gatekeeper is set to allow only OS X App Store and Developer ID signed applications. Unless your app is signed with a Developer ID certificate provided by Apple, your application will not launch on a system with Gatekeeper's default settings.
For information on the signing certificates available, see Code Signing Tasks on developer.apple.com.
The signing certificate contains a field called Common Name. Use the string from the Common Name field to sign your application.
Sign your app using the codesign(1) tool, as shown in the following example:
To verify that the app is signed, the following command provides information about the signing status of the app:
To check whether an application can be launched when Gatekeeper is enabled, use the spctl command:
If you leave off the --verbose tag, and it does not print any output, indicates 'success'.
For more information, see Distributing Outside the Mac App Store on developer.apple.com.
Submitting an App to the Mac App Store
Packaging an app for the Mac App Store is similar to packaging for regular distribution up until the step of signing the app. Signing the app for the Mac App Store requires a few more steps, and a different kind of certificate.
You will need to create an application ID and then obtain a distribution certificate for that application ID. Submit your app using Application Loader. For more information, see the following links (on developer.apple.com):
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved.
by Adrian D. Finlay
Did you know that you can use Java to make cross platform mobile apps? Yes, pinch yourself, you read that right the first time! I’ll teach you the basics of how to use your existing Java knowledge to create performant apps on Android and iOS in 12 easy steps. We will do this all using JavaFX as the GUI toolkit.
But first, some more foreground. You will need to meet the subsequent requirements to be able to build an application for both Android and iOS. However, if you do not desire to build an iOS application, you can feel free to develop on any x64 bit machine that supports Java SE 8. This project will be a Git repository built with gradle. But you do not need to create a Git repository.
The following are the requirements:
- A JDK 1.8 Compliant JVM
- Android Command Line Tools (SDK v.27)
- XCode 9.2
- Gradle 4.2
- Git Large File Storage (v.2.5.0) (Unnecessary if you do not want to create a git repository)
- Preferably at least 4G RAM
Impatient? Want to see an end result? Check out the completed project below.
afinlay5/OnyxFx
Gradle source code repository for OnyxFx, a cross-platform (Android/iOS/Linux/macOS/Windows) JavaFX app rendering…github.com
Gradle source code repository for OnyxFx, a cross-platform (Android/iOS/Linux/macOS/Windows) JavaFX app rendering…github.com
My development environment will be Fedora Linux 28 and macOS High Sierra. Now that we’ve got that out of the way, let’s dig in.
1) Create a folder to house the project
I hosted my project, OnyxFx, as follows: “/home/adriandavid/Projects/OnyxFx”. You are, of course, free to host the project wherever you please.
2) Initialize gradle, Git, set JAVA_HOME
Open a terminal in the root of the project directory. If gradle is properly configured, you should see something like this after executing the following command:
You need to make sure that gradle lists your Java Development Kit (JDK) 8 installation adjacent to the section labeled “JVM”.
While there are many ways to do this, the most straightforward way is to ensure that your JAVA_HOME environmental variable is properly set.
Depending on your environment, there are many ways to do this. One way to do this in most *nix environments is to set the variable in /home/<user>/.bashrc or /etc/profile. See the manual for your operating system to ensure that your JAVA_HOME environmental variable is set correctly.
You can include the following lines at the end of either .bashrc or profile to ensure that JAVA_HOME is set correctly.
Note: You may install Oracle’s JDK 8 here.
Then, make sure that the shell reflects the above changes by running one of the following commands:
Enter the following command to verify that the variable is correctly set:
If you are still experiencing difficulty or you are using Microsoft Windows, see here.
First, run
git init
in the project’s root directory to initialize the Git repository. Note: should you not desire to host a git repository, you may skip this step.
Second, run
gradle init
in the project’s root directory to initialize the gradle repository. This step is required.
Note: You will notice that my example appears slightly different. This is because I already have gradle and Git initialized on my local environment.
3) Get groovy! Edit gradle.build and
Hopefully Earth, Wind, & Fire can help you get groovy! Power up your favorite text editor, and edit your build.gradle located in your project’s root directory and replace the contents with the contents of the following GitHub gist.
These build.gradle settings configure our gradle project to use the javafxmobile plugin, which is the work horse of our project. You can learn more about the plugin here and here. Among many things, the javafxmobile plugin automates the process of downloading (from Maven Central or jcenter) and adding the iOS and Android SDKs to your application’s classpath.
If you are familiar with gradle, maven, or ant, great — you probably have an idea of what’s going on. If you are not familiar with gradle, don’t worry about it. All you need to understand is that gradle is a build tool used to automate many tasks involved in building apps such as: grabbing dependencies, project organization, and so on.
Notice that we are targeting Android 7.1 Nougat (API version 25) and iOS 11 (we will see where this is done shortly). You may adjust these values as you see fit. Note, however, that in the case of Android, you must ensure that the API version matches the version of the SDK that you have download (more on this later).
Lastly, I will not demonstrate the production of signed executables in this tutorial. For this reason, iOSSkipSigning is set to true and we do not make use of the releaseAndroid gradle task. You can, however, provide the appropriate accommodations to produce signed apps.
4) Make a new file called gradle.properties and configure it
Create a new file in the project’s root directory called
gradle.properties
and add the following content to the file.
These settings tell the javafxports plugin to use an iPhone-7 as the on-board emulator, to target iOS 11, and to pass the Xms and Xmx flags to the JVM, which specifies both the initial memory pool to 4GB and the maximum heap memory pool to 8GB. This will be necessary for the compilation of the openJDK and the development of the iOS build.
5) Install Homebrew (iOS only)
If you do not have a Mac and are not intending to produce an iOS build, feel free to skip this step.
Open the terminal in macOS and paste the following command.
6) Install the USB Multiplexing Socket (iOS only)
Only move on to this step if Homebrew has successfully installed. If you do not have a Mac and are not intending to produce an iOS build, feel free to skip this step.
Open the terminal in macOS and paste the following command.
7) Grab the Android Command Line Tools
Grab Android Command Line Tools for your platform here. After the download has finished, unzip the folder and paste the contents in the directory of your choice. For me, this was
/home/<user>/A
ndroid.
8) Set Android_HOME, Grab necessary Android packages
As with Java, gradle needs to know where to look to find the Android Command Line Tools. There are a few ways to do this. However, in the spirit of simplicity and consistency, we will set the ANDROID_HOME environmental variable in this tutorial. Add the following variable in the same way that we did it for JAVA_HOME. For example:
Remember to reload the shell by adding
source <fi
le> as we did for JAVA_HOME.
Now, grab the tools necessary to build the Android build. Execute the following command:
Take careful notice that the SDK and API version we have specified in gradle.build correspond to the version we have specified in this command. Namely, “25”. Should this be misaligned, the build will not succeed.
9) Create the application’s directory structure
Dell openmanage server assistant download. To automate the process of creating these directories, execute the following shell script.
Bourne-Again Shell / Korn Shell:
Windows Shell (cmd):
![App App](/uploads/1/3/4/0/134069252/263271906.png)
Save the file as mkpdir.bat or mkpdir.sh and execute the file from the project’s root directory as root (or Administrator).
Notice that we created directories for embedded and desktop. We will produce a desktop build, because it takes no additional work to do so. However, we will not produce any builds for embedded devices. https://ddtzdn.weebly.com/gas-turbine-simulation-program.html.
10) Create your JavaFX Application!
Navigate to /src/<platform>/java and begin developing your JavaFx application! Application resources are stored in /src/<platform>/resources.
You can start with a simple Hello World application or look at the source code that I have put together here. OnyxFx is an application I made, following these instructions, that makes REST calls over HTTP to the OnyxFxAPI. The API, in turn, is a web scraper that will return the statistical data (points per game, rebounds per game, assists per game) for the NBA® player and season the client specifies. It returns the data as JSON, which is then parsed and displayed to the screen of the mobile app. Feel free to edit it!
Keep in mind that although you can share source code, you should include custom edits in each copy of the source, should you want to make device specific changes.
Also note that the underlying compiler (MobiDevelop’s fork of RoboVM) does not fully support all Java 8 APIs. If you look very closely at my source code, you will notice that in the iOS version of the source code, I have removed unsupported API such as java.util.function.BiConsumer and java.util.Map.replace().
11) Create a RAM disk for iOS builds (iOS only)
The compilation process for iOS is very resource-heavy, as the plugin will compile the entire openJDK and other libraries twice to create a fat JAR that it will use to build your application. Therefore, you should preemptively create a RAM disk to accommodate for the memory requirements.
This step, however, is subject to your judgement of your machine’s capabilities. For context, the macOS machine that I used to compile my iOS app has 4GB of DDR2 RAM. I decided to make an 8GB RAM disk. To do so, execute the following command in the terminal.
12) Build and Run your application!
To build your application, execute the gradle wrapper in the root directory from the terminal as follows.
This will produce a desktop application packaged as a JAR with scripts to run the application provided in
/build/distributions/<AppName.t
ar>; and /build/distributions/<App
Name.zip>. Should you unzip the directories, you will notice the following structure:
Notice that in /bin there are scripts to execute the application. These scripts rely on preserving the current folder structure. Also notice that is not necessary for you to have tree installed. It is used here simply for illustrative purposes.
There is, additionally, a standalone JAR that you can use to execute the application on any desktop environment supporting JavaFX 8. To run the application, execute one of the following:
View this project’s gradle tasks
Make A Java Based App Work On Mac Computer
You can view this project’s gradle tasks by running the following in the project’s root directory.
To Compile, Run on Desktop
The following command will run your project in the host environment.
You will find a standalone jar in
build/libs/<AppName&g
t;.jar .
To Compile, Run on Android
You will find two APKs in
The first will be named
The second will be
build/javafxports/android
.The first will be named
<AppName&g
t;.apk.The second will be
named <AppName>-u
naligned.apk.
To Compile, Run on iOS
You will find three executables in
The first will be named
The second will be
The third wi
build/javafxports/ios
.The first will be named
<AppName&g
t;.ipa.The second will be
named <AppN
ame>.dSYM.The third wi
ll be named &
lt;AppName>.app.
Some screenshots of my sample app
Make A Java Based App Work On Mac Os
On Desktop
On Android
Make A Java Based App Work On Macbook
On iPhone
On iPad
Splash Screen
My Closing Thoughts
javafxports is a promising project that aims to bring JavaFX and the Java SE platform onto mobile and other devices. In a way, the tool parallels Xamarin in its efforts. Workshop manuals mitsubishi free download. However, the project has a lot of work left to be done.
For a start, the plugin currently does not fully support Java 8. On Android, it uses retrolambda to handle Java 8 Lambda Expressions & Method References. It technically is up to Java 6. Additional dependencies make it such that you can use Java 8. However, the process is straightforward, the builds work as expected, and the compilation time is not too long. Mac os sierra download problems.
On iOS, however, the builds are extremely memory-intensive and the compilation process takes a very long time. The following is a snippet of the log for ./gradlew createIpa task.
In total, the process consumed about over 6GB of RAM on my machine. Ios 6 jailbreak download mac. This is hardly ideal. However, the future is promising. A company called Gluon has developed a high performance, fully modular custom JVM fully supporting Java 9, that you can read more about here.
This article is originally published on the blog section of my homepage, here.
Resources to explore:
Run Java On Mac
- JavaFxMobile Plugin Git Repo: https://github.com/javafxports/javafxmobile-plugin
- JavaFxPorts Documentation: http://docs.gluonhq.com/javafxports/#_how_it_works
- JavaFxPorts Homepage: http://javafxports.org/
- Gluon Documentation: https://gluonhq.com/developers/documentation/
- Google Groups Page for JavaFxPorts: https://groups.google.com/forum/#!forum/javafxports
- StackOverflow Page for JavaFxPorts: https://stackoverflow.com/questions/tagged/javafxports
- Gluon Mobile Pricing/License Options: https://gluonhq.com/products/mobile/buy/