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.
Related
I am trying to incorporate Apple's script engine in my java app developed for macOs. I use eclipse to develop and when I run a debug build from eclipse all the Apple Script functions work.
As soon as I export it to an external jar and run that on the same machine they do no longer work.
I've searched and found some issues which I all tried, here is a summary:
using getEngineByName("AppleScriptEngine") now.
Adding the META-INF file javax.script.ScriptEngineFactory with the contents: apple.applescript.AppleScriptEngineFactory
cleaning and rebuilding several times
I opened the jar to see if the META-INF file is present and it is.
searched in /System/Library/Java/Extensions/ for a applescript jar file but it was not there.
I also searched for the /Library/Java/JavaVirtualMachines to see if it is there but also not the case
It is still not working. So I do not know what the difference is exactly between eclipse debug run and running a jar in macOs but there has to be something I am missing.
As far as I can figure out it seems that the apple scripting class is not installed but then how does eclipse use it?
As I understand there is a difference between java JRE versions so I am in need of a solution for all of them because I do not know what systems are running my app.
Any help is appreciated!
I'm having some trouble getting IntelliJ to output my packaged JAR file so I can run it directly from the command line.
Are there any free stand alone packagers which I can use to manually add all my JARs and specify my main class which will properly package the JAR? I'm really only interested in a packager, not an installer with fancy windows etc.
I'm using Ubuntu and developing JavaFX applications.
I did find these and these links... I'll give Install Builder and lzPack a go and hopefully report back with a positive result.
UPDATE
Install Builder seems to require a paid license to distribute your packaged jars. Unfortunately izPack does not seem to work when I execute it from the command line using Java 9. Crashes out.
Trying Oracle's javapackager command tool next.
Looks like I need to use Ant to deploy standalone JavaFX applications.
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.
I have made sample application with JavaFX using netbeans 7.2. When I run application from netbeans it is working fine. Now I want to distribute this application as the standalone application.
So I am trying to opening this application from the executable jar file made by netbeans itself in the dist folder. But I am getting error : Unable to Load JavaFX runtime
How to resolve this issue ??
Also I wanted to know the best way to distribute this application as desktop standalone application ? Means I wanted to know the final package for distribution would it be executable jar file ?
For this final package(suggested for above question) will there be any prerequisites for the application to run on windows environment ? : This is importance because our final environment is very limited. It don't have even java installed on it.
I don't know why launching the executable jar created by NetBeans does not work for you.
You can workaround this issue by packaging your application as a Self Contained Application. Such a package includes the java and javafx runtimes with your application so you never need to worry about distribution and installation of these things to your client. In any case, it sounds like such a package is a good fit for your application.
A self-contained application is a wrapper for your JavaFX application, making it independent of what the user might have installed.
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.