I'm trying to distribute a JavaFX application.
As an example project I took the JavaFX and NetBeans -> Non-modular with Maven. The code can be found here: GitHub: openjfx/samples.
On my machine this application works. But when I try to run that JAR on another machine, it says:
Error: JavaFX runtime components are missing, and are required to run this application
In the section Non-modular with Maven, that problem is being addressed. As a solution it suggests:
Properties -> Libraries -> Run -> Modulepath -> + -> Add Library and add the JavaFX12
But my project properties look different. They are missing Libraries:
Both machines run on Ubuntu and Java 11.
In my case, I work with windows systems, but I think that it's similiar on linux. the problem is that openjdk and javafx no always are available on other computers and dont are included on .jar.
When I want use my app on a other computer, I must build an installer this content:
myapp.jar
openjdk library folder
javafxsdk library folder
And on shortcut I indicate the runs commands calling all modules that I use on my app:
--module-path="../../javafx-sdk-11.0.1/lib/" --add-modules="javafx.web" --add-modules="javafx.controls" --add-modules="javafx.fxml" --add-modules="javafx.base" -jar ../../myapp.jar
In your case, maybe you only needs create a shortcut with commands and indicate correctly the routes of your .jar, openjdk and javafxsdk and, of course, download them on the computer that runs your app.
Related
I tried installing javaFX on my eclipse and it worked fine at first. Then I decided I want to make a specific JRE to save me from doing all the extra steps (adding user library each time, etc..) and I think I followed the tutorial well but now the programs won't run and I get this message from the JVM launcher:
(Error:--add-- modules requires modules to be specified)
note: the compilation works fine but after running it that happens
I'm not very experienced with these types of things and I have no idea what I did wrong so please ask me for any necessary details
any suggestions?
Information on VM arguments for adding modules is in the documentation:
Eclipse: non-modular from the IDE
Add VM arguments
To solve the issue, click on
Run ->
Run Configurations... ->
Java Application
create a new launch configuration for your project named hellofx and
add these VM arguments:
--module-path "\path\to\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml
This should be done if the JDK or JRE you are using does not include the JavaFX modules in its base module layer (which applies to most common JDK or JRE distributions) and you are executing your application via the IDE (e.g. not via maven with the javafx-maven-plugin).
FAQ
Then I decided I want to make a specific JRE to save me from doing all the extra steps
You don't need to build your own JRE with JavaFX modules.
You can use a pre-built JRE (or JDK) that includes JavaFX:
Azul Zulu JDK FX 19 Win x86 64 bit OR
Liberica "Full JDK"
With either of those, the JavaFX modules are included in the base JDK. That means you don't specify JavaFX libraries in build tool dependencies, or manually in the IDE, and you don't need compile or VM arguments for JavaFX modules.
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.
I am attempting to build an application in NetBeans that can be deployed to and end user. I am still pretty new to deploying projects and this is by far the most complicated one I have done so please bear with me. I currently have a working application in NetBeans which utilizes JDK 15 and JavaFX 15. As long as I run things inside of NetBeans everything works as intended. I have reached a point where I want to make sure I can distribute this application outside of NetBeans. To this end I did some searching and found the following tutorial.
https://netbeans.org/kb/articles/javase-deploy.html
I was able to follow the tutorial and build the example. The build works in NetBeans, I am able to run the executable jar file in the dist folder from the command line, and I am able to run the jar file by executing it from the file explorer. Now when I attempt to do the same process with my own project I run into the following errors.
When I attempt to run the jar file in the dist folder absolutely nothing happens.
When I attempt to run the jar file from the command line using the command
java -jar "C:\Workspace\HandyAndyVersion1_2\dist\HandyAndyVersion1_2.jar"
I receive the following error,
Error: JavaFX runtime components are missing, and are required to run this application.
I am currently under the assumption that the first problem is a by product of the second. If anybody has a solution to this problem or any ideas on what I could have configured wrong please let me know and thank you all in advance.
To package a Java desktop application these days, you should be using the jpackage tool and optionally the jlink tool. These will generate a JRE image that is packaged with the application and contains the modules you need.
I suspect the issue you are running into is that the native libraries for JavaFX are not present. Most distributions of JDK 15 do not contain the JavaFX modules, though some do. (See the Full and FX bundles of the JDK from Azul and Bellsoft). I find it is easier to use a JDK with JavaFX bundled rather than have to manage a separate module path during development for the jmod files of JavaFX, but that is another option. Either method can be used with jlink to create a suitable JRE for your application that includes the JavaFX modules.
I am working on a large JavaFX application which is due for deployment. I want to wrap the .jar files with Launch4j and create an installer using Inno Setup. However, I am having trouble with the process.
When using Launch4j, it spits out these errors (see 1). However, despite these errors, everything works perfectly fine using an MWE I created to verify that Launch4j wraps jar files properly. The MWE is just a small JavaFX application, where I use Launch4j to generate an .exe file and use Inno Setup to generate an installer. I can install this MWE with no issues using the generated installer and run the app. As mentioned, however, when I follow this exact same approach for my large application, which does have a lot more dependencies, I am not able to run the application after using the generated installer.
I searched for solutions to this and found this work-around using Inno Setup (see ban-geoengineering's answer):
How do I bundle a JRE into an EXE for a Java Application? Launch4j says "runtime is missing or corrupted."
I followed the steps mentioned but am still not able to run the application after generating the jar wrapper with Launch4j and running the generated installer created by Inno Setup. When I try to run the app, simply nothing happens.
Application information and development environment
The application utilizes custom-made java libraries developed in-house which act as an intermediary to communicate with a device's eSW through a custom interface. These java libraries and device drivers are needed in order to communicate with the device and need to be delivered with the application, as in included with the installer. I am using IntelliJ IDEA 2018.1 under Windows 10 Enterprise. The JDK is version 9.0.4.
Steps taken prior to using Launch4j and Inno Setup
I have followed the steps mentioned here https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-application.html#package to package the application. I can successfully run the application via the commandline using java [options] -jar nameOfJar. The application needs certain VM options in order to communicate with the device drivers, and I am suspecting the issue lies here when generating the .exe file and generating the installer.
Addition 1
I have tried to add a custom classpath in Launch4j. It seems that Launch4j does identify the jars that the main class is dependent on, as it includes all the proper jar files (see 3).
I have in addition to this tried to mimic the JVM options I use to run the application via the commandline (see 4).
When executing the application it spits out NoClassDefFoundError and says it is due to the com/demant/gearbox/corona/model/GBCManager. However, this should already be included via the jar file com.demant.gearbox.corona.model.jar, as you can see in 3.
But, as you can see from both 3 and 4 the NoClassDefFoundError is still thrown.
Can I execute Eclipse Java development tools as a standalone process? I need to get Java program's AST structure using Eclipse JDT from another program, and to do that, I need to execute eclipse plugin as a stand-alone process behind the scene.
Is that possible? If so, how one can do that?
Eclipse/jdt and eclipse/ast is nothing more than a jar file, so one can use them to build standalone java application.
Example
I googled to find ASTExplorer as an example to make eclipse/ast plugin as a standalone java project.
The program was targeted for pretty old eclipse (3.0.2), I downloaded the 3.0.2 for Mac OS X this site - http://archive.eclipse.org/eclipse/downloads/drops/R-3.0.2-200503110845/
You need to setup ECLIPSE_HOME classpath variables in Preference -> Java -> Classpath variables
The .classpath has those classpath variables already, you can refer to this post - .classpath contents update in eclipse. As you can see it refers eclipse/jdt(art) jar files. I'm pretty sure one can change the reference to the newest version of jdt/ast without downloading the 3.0.2 version.
As I use Mac, I need to replace the swt for PC with swt for Mac. I could do that in BuildPath/Configure Build path
First remove the PC swt reference.
Then add the correct Mac swt reference.
Compile the example with the eclipse indigo/on mac
When the setup is correct, eclipse starts building the project. You can use Project -> Build Project menu. Then, you can check the application works fine in eclipse.
Generate the executable jar
Export to executable jar file.
You'll get some warnings, but you'll have a jar file.
Execute the generated jar
Just executing java -jar ast.jar doesn't work on Mac, I got a hint from this post.
Running SWT based, cross-platform jar properly on a Mac
In short, you need to run java -XstartOnFirstThread -jar ast.jar
Does it have to be Eclipses's AST? Or is any AST generation o.k.? If it doesn't have to be eclipse, I'd suggest Habelitz open source Java AST Compiler. http://www.habelitz.com/ I'm using it myself for some projects....
Well, of course you can launch eclipse just like any other process : How to create a process in Java
And then the problem becomes relaying the information back to the original process, which gets kind of messy. My suggested approach in this case would probably be to create a plugin in eclipse and have that plugin do whatever it is you think you need the AST for. You can work out messages with command line options to eclipse, or a shared file or something.