JavaFX - Deployed Application doesn't run on other PCs? - java

I have a problem with getting the Application to run on other People's machines.
I have tested a self contained and the normal .jar file.
When i pass them to a friend of mine who has java installed, when he opens the .jar file, there is an Error: "Java Exception has occured".
When i run both the .jar and the .exe off the self contained one, both do work on my PC.
So the actual question is:
Why isn't it working just like that?
Can't i just run JavaFX applications without installing the whole JDK?
Thanks for your help :)

Since Java 7 there exists the "javafxpackager", renamed to "javapackager" on Java 8 which uses some xml-configuration for generating your wanted "Installer"/distribution-package.
As this does not fit some peoples need, there exists a way to use maven:
the javafx-maven-plugin, you can find some examples about the usage of that plugin as linked.
Disclaimer: I'm the maintainer of the javafx-maven-plugin.

Related

Creating .exe from Java for people to use [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How can I convert my java program to an .exe file ?
I'd like to create a Windows .exe for a Java program. Previously, I've used JEXECreator for this, but it's not entirely satisfactory because:
The executable sometimes works on the machine on which it was created but not on others.
The program is commercial; if you use the trial version, it adds a nag screen to your application.
I don't need the generated .exe to work if Java is not installed on the target machine (in fact, I think this is impossible).
Any recommendations?
Launch4j perhaps? Can't say I've used it myself, but it sounds like what you're after.
Most of the programs that convert java applications to .exe files are just wrappers around the program, and the end user will still need the JRE installed to run it. As far as I know there aren't any converters that will make it a native executable from bytecode (There have been attempts, but if any turned out successful you would hear of them by now).
As for wrappers, the best ones i've used (as previously suggested) are:
JSmooth
and
Launch4j
best of luck!
If you really want an exe Excelsior JET is a professional level product that compiles to native code:
http://www.excelsior-usa.com/jet.html
You can also look at JSMooth:
http://jsmooth.sourceforge.net/
And if your application is compatible with its compatible with AWT/Apache classpath then GCJ compiles to native exe.
I used exe4j to package all java jars into one final .exe file, which user can use it as normal windows application.
You could try exe4j. This is effectively what we use through its cousin install4j.
The Java Service Wrapper might help you, depending on your requirements.
If Java is installed on the target machine, there is no need to create an .exe file. A .jar file should be sufficient.

Deploying a NetBeans application with JavaFX

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.

AppleScriptEngine in java jar is not working, what am I missing?

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!

Deploy to Windows Desktop

OK, I’m still a little overwhelmed by all the choices for deploying an application. My case is really simple. I have a Java program that’s now working in NetBeans on Win7. I want to run it on another Windows desktop that doesn’t have NetBeans.
The method presented here: https://netbeans.org/kb/docs/java/native_pkg.html produces a single .exe file that installs the application on the Win desktop. But, that file is huge because it includes all required portions of the JRE.
The method presented here https://netbeans.org/kb/articles/javase-deploy.html uses the JRE already installed on the Win desktop so the distribution is very small. But, it requires you to distribute both a .jar file and a lib folder.
So, finally, the question. Is there a method that uses the already installed JRE and only requires the distribution of one (small) file?
Thanks.
Since that second option has everything you need to run the app (provided that a JRE is available), you can use that with a third party install packager like izpack

How do I create an .exe for a Java program? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How can I convert my java program to an .exe file ?
I'd like to create a Windows .exe for a Java program. Previously, I've used JEXECreator for this, but it's not entirely satisfactory because:
The executable sometimes works on the machine on which it was created but not on others.
The program is commercial; if you use the trial version, it adds a nag screen to your application.
I don't need the generated .exe to work if Java is not installed on the target machine (in fact, I think this is impossible).
Any recommendations?
Launch4j perhaps? Can't say I've used it myself, but it sounds like what you're after.
Most of the programs that convert java applications to .exe files are just wrappers around the program, and the end user will still need the JRE installed to run it. As far as I know there aren't any converters that will make it a native executable from bytecode (There have been attempts, but if any turned out successful you would hear of them by now).
As for wrappers, the best ones i've used (as previously suggested) are:
JSmooth
and
Launch4j
best of luck!
If you really want an exe Excelsior JET is a professional level product that compiles to native code:
http://www.excelsior-usa.com/jet.html
You can also look at JSMooth:
http://jsmooth.sourceforge.net/
And if your application is compatible with its compatible with AWT/Apache classpath then GCJ compiles to native exe.
I used exe4j to package all java jars into one final .exe file, which user can use it as normal windows application.
You could try exe4j. This is effectively what we use through its cousin install4j.
The Java Service Wrapper might help you, depending on your requirements.
If Java is installed on the target machine, there is no need to create an .exe file. A .jar file should be sufficient.

Categories

Resources