Shipping a Gluon mobile application with Java 14 - java

Following this question Gluon Mobile project does not work with gradle 6, I want to know how to ship an application that uses gluon mobile and Java 14.
From what I read, gluon mobile only supports Java 14 if I use GraalVM with the client plugin (https://github.com/gluonhq/client-maven-plugin or https://github.com/gluonhq/client-gradle-plugin). I read https://github.com/dlemmermann/JPackageScriptFX to learn how to package a JavaFX app, but I don't think it's compatible with GraalVM's native image.
So it looks like I'm stuck. I can't use jpackage/link script above because I can't use Java 14, and if I use the client plugin with GraalVM to be able to use Java14, I can't use the jpackage/link script. How do I ship then?
Can I just ship a zip/jar with my whole gluon mobile app and the JDK module deps maybe? Then I won't need platform specific images or packaging.
My target platforms for now are Win and Mac, at least until I figure this thing out. I'm aware that everything here is quite new, so I'm not looking for miracles.

Related

Configure Java VM of Eclipse to run with JavaFX

I would like to know if it is possible to configure the Java VM used by Eclipse to run in this way, that it uses JavaFX SDK libraries.
Please be aware! I don't want to build JavaFX applications on my own in Eclipse, e.g. by using E(fx)clipse or other plugins.
Another remark: I don't use Java development perspective in Eclipse or a Java project. So it won't work to add the external .jars of JavaFX as user libraries!
In my use case I have an third-party GUI application based on JavaFX that has to be started out of Eclipse.
If I try to start this application I receive the following error:
The system reqirements are not met.
Could not find: javafx.properties
in:
/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.x86_64_17.0.2.v20220201-1208/jre/lib
Your Java Virtual Machine seems not to support JavaFX,
required to run the XXX.
Please make sure you provide a valid path to the Java FX
modules during gui installation.
As you can see by the error message my Eclipse runs on a MacOS x64 system.
But I think the way to configure the VM of Eclipse should work on each system the same way.
Thank you.
Steve
If you have a third-party GUI application, then you do not need an IDE like Eclipse.
Ideally the publisher of your app would have provided the app as a package that includes the JavaFX/OpenJFX libraries as well as all the parts of a JDK/JVM needed to run that app on your Mac.
If the publisher gave you only the bare-bones app without the needed libraries & JDK/JVM, you can obtain a JDK/JVM bundled with those libraries.
At least two vendors supply a JDK with JavaFX/OpenJFX libraries:
ZuluFX by Azul Systems
LibericaFX by BellSoft
Both are available free-of-cost with optional support plans available for sale. Download either product as an installer specific to your Mac, while paying attention to either Intel-based Mac or Apple Silicon (ARM, AArch64) based Mac.
You can verify the install by using a console such as Terminal.app to run:
java --version
… and:
which java
You can also use the Finder to locate your installed JVMs by choosing Go > Go to Folder… where you paste:
/Library/Java/JavaVirtualMachines
If your app contains the necessary MANIFEST.MF file, you may be able to launch your app by double-clicking. If not, use a console such as Terminal.app with the java command to launch the app.

Convert JavaFX GUI Maven app to M1 mac compatible app

I have written JavaFX app with Maven, now I want to convert it to executables. I was successful at generating .exe file for Windows using launch4j-maven-plugin, for mac I'm using appbundle-maven-plugin, it generates .app, but it doesn't work (for M1), saying JRELoadError, I think it's because of my cpu architecture as I'm not using x86 one, I've tried with few versions of jdk, including one that I use to launch it in IntelliJ.
So my complete question is this: How to get M1 mac compatible .app from Java GUI Maven project? (I prefer to have as a Maven plugin if possible).
You could earn yourself a few bonus points by giving this https://github.com/dlemmermann/JPackageScriptFX little framework a try. I don't have an M1 Mac, so I cannot try it myself but in principle this should work with maybe a few tweaks. You may have to upgrade to the latest EA builds of Java 18 and also JavaFX 18 because there have been some recent bug fixes.
Disclaimer: I am biased because I developed this framework together with Dirk.

How do I use JavaFX 11 in Eclipse?

I have some trouble with JavaFX. I wanted to start creating apps, desktop or mobile, at least something. So I found out I could use the JavaFX library for it. But as far as I understood, it was excluded from JDK 9. I'm actually using OpenJDK 11 on Ubuntu 18 (though Eclipse writes I have the JavaSE 10 environment, that is where I'm also a bit confused) and I installed OpenJFX using sudo apt install openjfx and I can't make Eclipse work with JavaFX.
I'm not sure if there's any sense not to use JDK 8 with the included JavaFX, but anyway, how can I use JavaFX in such conditions in Eclipse?
There are multiple points in your post which needs clarification. I will try to answer them in different bullet points:
But as far as I understood, it(JavaFX) was excluded from JDK 9.
JavaFX will be decoupled from Oracle JDK starting JDK 11. I stress on Oracle JDK because JavaFX was never a part of OpenJDK. Not even in OpenJDK 8.
I'm actually using OpenJDK 11 on Ubuntu 18 (Though eclipse writes I have JavaSE 10 environment, that is where I'm also a bit confused)
For Java 11 support in Eclipse, you need to install
Java 11 Support for Eclipse Photon plugin.
Here are a few Examples on how to run Java 11 applications in Eclipse
I installed openjfx using sudo apt install openjfx and I can't make eclipse work with JavaFX.
I'm not sure if there's any sense not to use JDK 8 with included JavaFX, but anyway, how can I use JavaFX in such conditions in eclipse?
Since OpenJDK 11 or Oracle JDK 11 will not come bundled with JavaFX, your best bet is to either download the JavaFX SDK from here or here and load them in your IDE.
If you are used to build tools, you can directly use the JavaFX runtime jars which are available in Maven Central.
For a tutorial on how to run JavaFX 11 on OpenJDK 11, you can follow:
Getting Started with JavaFX 11
JavaFX on JDK 11
JavaFX 11 and Eclipse
At the time of writing this post, you need Eclipse 4.9M3 to work with JavaFX 11.
Once you have eclipse, JDK 11 and JavaFX 11 SDK, you can either opt to create:
Module based project
Non-module based project (No module-info.java required)
Module based Project
Create a Java project and add JavaFX jars from the Java FX 11 SDK to the module path of the project.
Create a module.info and declare its dependency of javafx.controls module. javafx11 is the name of the package which contains your Java file.
module javafx11 {
requires javafx.controls;
exports javafx11;
}
Run the program \o/
Non-module based Project
Create a Java project and add JavaFX jars from the Java FX 11 SDK to either the module-path or classpath of the project.
Add the following JVM args to the run configuration of the project:
--module-path=path-to-javafx-skd/lib --add-modules=javafx.controls
Run the program \o/
tl;dr
To most easily get started with JavaFX, use the Oracle-branded release of Java 8 where JavaFX 8 is bundled and easily available.
For technical details, see Using JavaFX in JRE 8. Look to the Linked and Related sections of the web page for many related postings.
Java Modularization
The Java platform is in the process of a sweeping reformulation, known as modularization.
Previously, Java SE (standard edition) was one big monolith of software, ever-growing with more and more being added. No single app ever uses all of it.
A decision was taken to break Java SE into many separate chunks to be defined formally as “modules”. One major benefit is that an app may be bundled with a Java SE runtime composed of only the modules actually needed, with unused modules omitted. See the jlink tool.
As a byproduct of this modularization, some older and less-popular parts such as CORBA are being dropped, to no longer be carried as a standard part of Java (though offered for other parties to pick up if they so decide). Similarly, some Java EE related modules will be removed from Java SE and turned over to the Jakarta EE project, logically a more appropriate home. See JEP 320: Remove the Java EE and CORBA Modules.
The process of modularization and reorganization is a years-long ongoing effort. Much was done in Java 9 and Java 10. Some of the final steps are being done in Java 11.
One of these steps being taken in Java 11 is to cease bundling JavaFX with Java SE. See:
The Future work section of the JavaFX Wikipedia page
The 2018-03 Oracle blog post, The Future of JavaFX and Other Java Client Roadmap Updates
The 2018-03 Oracle white paper, Java Client Roadmap Update
The curse, May you live in interesting times
So getting started with JavaFX development right now will be easiest if done with Java 8. The JavaFX libraries are bundled in with Java 8. And you need not learn about modularization, nor need to wrestle your IDE (such as Eclipse) and project settings to recognize modules. If you do not have a pressing need to use the very last versions of Java or JavaFX, stick with 8 until the modularization process and tools gets smoothed out, likely next year 2019.
If you insist on using Java 11, you need to learn about:
Java modularization in general, including the module-info.java file.
Updating your IDE (Eclipse, etc.) and other tools to later versions supporting both modularization and Java 11.
Configuring modules in your build tools, such as Maven or Gradle
Configuring modules in your IDE, such as Eclipse
Downloading JavaFX modules, or using a dependency manager such as Maven to do so
Those points are too much to cover here, and have been covered in many other Questions on Stack Overflow. Besides, Java 11 has not yet been formally released.
Perhaps this article will help, How to Create a Project With JavaFX on JDK 11.
To learn much more about Java modularization, read the blog and the book, The Java Module System, by Nicolai Parlog.
I've had to struggle through this on about 20 computers now, so I made the following checklist:
[ ] download javafx11 from javafx11's website, put on desktop
[ ] create a MODULE based project
[ ] right click project, go to BUILD PATH
[ ] add the downloaded javafx.base/control/graphics as external jar files
[ ] put the files in a package (eg: my_big_package)
[ ] put the following in the module.java file:
module javafx11 {
requires javafx.controls;
exports my_big_package;
}
[ ] eat a donut from the break room
If you're not married to Eclipse and/or just trying to learn (or are a student with an unhelpful professor/TAs), BlueJ currently has JavaFX already built into it and ready to go, so no extra setup or download is necessary. Neat!

JavaFx won't download on my MacBook Pro for Eclipse Oxygen

I have an assignment for my school that I have to submit that needs you to create a Java application that involves recursion, file read, and javaFx. I have a 15 inch MacBook Pro with an i7 processor. When I try to use JavaFx in a class in Java, I always get errors saying that javaFx.application.Application or javaFx.scene.Scene cannot be applied to a type. Basically, my Java oxygen application cannot run javaFx. I've tried multiple YouTube videos on how to download plugins from oracle and the Java oxygen marketplace. I told my instructor and he hasn't gotten back to me yet. Everytime I download a possible plugin like e(fx)clipse/2.0.0/ (or something like that), Java oxygen sends a message that it cannot complete the operation because new software has already been installed. I kept searching oracle for the latest JDK but javaFx still won't download. I was just wondering if it had to do with me having an Apple and not Windows computer or is there something else I can try. Thanks for your help!
Just go here and download the Mac version of the JDK and install it.
http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html
That is all which is technically needed to run a JavaFX application. You should also download and install the latest version of Eclipse (Photon) because it fixes some problems with the latest Java.
http://www.eclipse.org/downloads/index-developer.php
If you like you can also install e(fx)clipse from the marketplace but it is not needed to write JavaFX applications.

How to integrate PhoneGap into an Ant build?

I've been reading up on PhoneGap and really like it. I'd like to see if I can use it with GWT to write Java apps that deploy to many different platforms (web, mobile web, android, iphone, winphone, etc.).
It looks like the PhoneGap SDK comes with different versions of cordova.js for each native platform you want to support. So it looks like the Ant build will have to somehow package the GWT-generated JavaScript to the correct version of cordova.js:
3098DJU39I4F9IF9.html + cordova-android.js
3098DJU39I4F9IF9.html + cordova-iphone.js
3098DJU39I4F9IF9.html + cordova-windows-phone.js
I'm generalizing here, and I know those aren't the correct file names (although, obviously, 3098DJU39I4F9IF9.html is the GWT-generated code).
But then something has to kick-off PhoneGap's ability to take each of those pairings and produce the correct packaged container: an APK, IPA or XAP for each platform respectively.
So I first ask: how does a PhoneGap developer normally go from 3098DJU39I4F9IF9.html + cordova-android.js to having a myapp-android.apk, or from 3098DJU39I4F9IF9.html + cordova-iphone.js to having a myapp-iphone.ipa? Does the PhoneGap SDK have a command-line tool that does this?
Once I understand that much, I'm trying to figure out how to automate this packaging/binding process from an Ant build. Are there any known Ant tasks that already do this? Or do I need to kick off a shell from inside Ant and just run the shell commands? Thanks in advance!
#rooftop is right, you have to build the native app using native SDK even if you are using Phonegap. The benefit lies in creating the UI and behavior of the app using HTML5, CSS and JS.
So, if you are not using any of the native functionality or custom Phonegap plugins, you can just have a bare minimum package structure of native apps for each of the platforms and then simply move the correct files into the concerned folders (in Android it is assets folder) of those package structures using copy task of ant. Thereafter, you can use command line compile and build tools specific to each platform to build and package the app.
Hope this helps.
EDIT: Added more details about other platforms
Basically, all SDKs contains command line tools. In fact I used to compile and build from command line, to automate the process, even for standard Windows apps (Console, Web Apps etc) which are usually performed via Visual Studio's easy to use environment. You can see this for extended tools over standard SDK for Windows phone development.
Similarly iOS is based on UNIX so there we get the power of majority of command line tools for compile, build and automation and XCode provides command line tools for building.
Further for Android, you may find this helpful.
You should really be using Cordova, the renamed version of PG that is an Apache project now. Command line tools were recently released for Cordova. I have not used them so I am not sure if they will help you with building or not. Typically the way you woul create the binary for the device, say an IPA file for iOS would be to actually use Xcode and the native SDK to compile and package your app. This means you need all of the native tools and SDK for each platform. There is also a hosted service from Adobe that will build the native bits for you for a fee. It used to be called phone gap build, not sure if that is still the name. You might want to look at IBM Worklight, as it does many if the things you asked about. The developer edition is free an Eclipse based for the IDE.

Categories

Resources