Runnable Jar from a JavaFX 8 project, JavaFX compenents are missing - javafx

i created a Javafx project using JDK 8 and when i tried to export it to a runnable .jar file, i got surprised that it doesn't run using CMD, and gives the following error :
"Javafx compenents are missing"
while it works perfectly during the compiling time(using the IDE) when i accessed the .jar files, i found it has just .class files (that i made), and the needed library files that haven't been exported (i made sure to select the "extract need library files extract required libraries into generated jar" option in Eclipse), is there a reason behind of this? and a way to solve it? thanks in advance
Ps: i tried this using Eclipse and Intellij IDE
I just wanna mention once again that I'm using JDK 8 where it has JavaFX library inside of it.

Did you try this?
There are detailed instructions on how to configure your IDE to run JavaFX with newer OpenJDKs (which do not come with JFX components in it).
It also explains how to create a new JavaFX Maven project from archetype, with all the necessary plugins to easily build your application while including the minimal Java components for it (using jlink).
This will ensure that anybody using your application will have those components.

Related

Unable to create a JavaFX project in Netbeans IDE 16 [duplicate]

I've been banging my head on this one for ages and all of the tutorials I've found don't seem to work. When I try to create a new JavaFX project in Netbeans 14, using JDK 18 and the latest JFX download for Windows here:
https://gluonhq.com/products/javafx/
Also tried with JDK and JFX 17 and still no luck. I get this error:
I've added the libraries like so:
If I try to add the platform folder, it won't let me progress through the dialogue:
I can't find solutions to this anywhere and, again this is the same with JDK 17 and 18, and JFX 17 and 18. I've checked the documentation and there's nothing that seems to solve the issue.
It says to go to the JavaFX tab and enable JavaFX, but there's no JavaFX tab... Unless they mean this:
But if that's it then, as you can see, it's already enabled and it's still not working. I'm totally lost. I don't understand why the documentation is so poor for FX, for every IDE. It's honestly like they don't want people to use it and every tutorial I'm finding is using outdated versions of NetBeans, the JDK and JFX D-: (they also don't solve the issue even if I do follow them).
If anyone could help guide me, I'd really appreciate it.
I would suggest you go to New Project -> Java with Maven -> either Simple JavaFX Maven Archetype(Gluon) or FXML JavaFX Maven Archetype(Gluon). Use the POM to change your version of JavaFX from the default to whatever version you like. I also use the POM to change the JavaFX-Maven-Plugin to the latest version.
I strongly endorse the approach using maven suggested here. This project started exactly the same way; I'd welcome learning of any issues you encounter.
Alternatively, follow the steps outlined in JavaFX and NetBeans: Non-modular projects: IDE. You've created a JavaFX library, but "Don't try to create a JavaFX project." Instead, choose Java with Ant and Java Application to create a new project, shown below, then follow the remaining steps carefully. It's a convenient alternative for a scratch project while you assay maven.
Addendum: The ant code for a JavaFX project, not selected in the image above, may attempt to package dependencies that are no longer required. In particular, a project using module javafx.web may fail with the following error, seen here and here. The easiest fix is to recreate the Java application by choosing Java Project with Existing Sources.
Unable to create javax script engine for javascript.
Alternatively, a simple example using a custom ant script is cited here.

MySQL-Connector does not work after using JLink in a JavaFx project

I am trying to create an executable out of my JavaFX project that uses mysql-connector driver to connect to a local database. After i generate the JLink folder via the pom.xml file, when i run my application, the connection between the database and the app does not work (Running the application in the IDE makes everything work fine). I am using InteliJ as my IDE, MySQL for the database and i think the connector is a jar file without a module-info.jar file which is causing issues in JLink.
I did some digging and i found out that mysql-connector can not be added directly via Jlink. I've seen some workarounds (for example: moditect) but i still can't figure it out. Any help is greatly appreciated!
You can't use jlink to directly create an executable file if your application is not fully modular. However, you can use a combination of jdeps, jlink and jpackage to create an application bundle or an installer. You might want to have a look at this tutorial: https://github.com/dlemmermann/JPackageScriptFX

How to run javafx with maven desktop application from a jar file outside Netbeans 11 on my laptop or another ones?

I am working on Netbeans apache 11.1. I developed so many desktop programs using java and could run them almost on any computer. But when I moved to JavaFX technology with maven I wanted to redevelop almost the same desktop apps using JavaFX, and everything worked fine into Netbeans 11.1. The problem is when I want to jar my apps and distribute them outside of Netbeans they actually do not work.
I tried everything I did in the past (which worked just fine) for instance: adding Class-Path and setting Main-Class to manifest but still does not work. I searched through a lot of forums and sites but still cannot run my app outside of Netbeans.
My code is as any code combination of JavaFX, Maven, CSS, and FXML. Everything works just fine into Netbeans. The problem is outside of it.
Although I've added openjfx-12.0.2_windows-x64_bin-sdk to windows environment path, when I attempted to run jar that's been generated by Netbeans using cmd I just get this ERROR: javafx runtime components are missing, and are required to run this application. ANY HELP PLEASE?
I don't know if I'm understanding your problem right (if not I'm sorry).
Runnable JAR JavaFX
What once helped me, was create a new run configuration (in intellij) with the main class and the JRE. After that I created a Run Maven Goal with the command line
assembly:single

Netbeans 7.2.1 broken reference : dist.jar (when coding on a JavaFX file)

I'm trying to learn JavaFX with reading some tutorials however, I couldn't even implement the "helloworld" application. The NetBeans said:
Error: Could not find or load main class helloworld.NewFXMain
Java Result: 1
and then when I checked Properties-->Libraries-->Run part there is a warning which says
Broken reference : dist.jar
How can I solve this?
when you create a new project in java fx and want to run the project for demo then this error occur .
you can try it given below:-
1.right click on project.
then click on clean and build.
its running your project in netbeans.
Before running, try "clean and Build Project" option.
Menu->Run->Clean and Build Project
then run your project.
It worked for me.

java.lang.UnsatisfiedLinkError: no db_java-4.2 in java.library.path

I'm trying to access a Berkeley DB database file (say Test.db) from the java code and then want to read all the pairs from it. I'm using the com.sleepycat.db.* and com.sleepycat.bdb.* packages ( NOTE: Not Oracle Berkeley DB JE )to do this task. For the implementation, I did exactly as described in this BerkeleyDB Java API Tutorial
So, when I run this project from eclipse I got this error
Exception in thread "main" java.lang.UnsatisfiedLinkError: no db_java-4.2 in java.library.path
and from the stack trace, source for this exception occured from this line
env = new DbEnv(0);
I tried to set it from the java command
$java -D<name>=<value>
but still it didn't work.
My goal is to export this project into a jar file and use it to read BDBs anywhere . Anyone who knows how to get out of this, I appreciate your help. It would be great if I can be redirected to any working tutorial for accessing Berkeley DBs from java code too. Thanks !!
SOLUTION: After a lot of work, I found out that the Sleepycat API that I'm working on is using native libraries that are written in C/C++ through the JNI. Berkeley DB that is installed on my PC didn't have the shared object file db_java-4.2 (to be accurate, file name is libdb_java-4.2) which means that this BDB is not configured for java APIs.
So, the solution is to start the installation of BDB from scratch again by enabling the java configuration.
I had the same problem.
Like kK_Pulla mentioned, the sleepycat API using native libraries written in C/C++ through the Java Native Interface. So making Sleepycat API calls means the java code is ultimately going to call compiled C/C++ code.
If you are getting the "java.lang.UnsatisfiedLinkError: no db_java-4.2 in java.library.path" error then it is likely that, at least it was in my case, you have not included the relevant native libraries in your project.
I would describe what I did to fix it in my case. Firstly let me describe my environment.
IntelliJ maven Java project on a linux machine.
Built Berkeley DB version 18.1.40.
The Berkeley build included the --enable-java switch in the configuration phase.
I included the db.jar (found in the build_unix directory) as a module dependency through the Intellij menus File> Project Structure. I selected Modules under Project settings on the left pane and then under the dependencies tab I added the db.jar file as a dependency.
This was the state of my project before I encountered the UnsatisfiedLinkError. To fix that I added the native libraries (found in the unix_build/.libs directory) to the project. You can do this by selecting the File menu> then Project Structure. On the left pane under project settings select Libraries and then click the + sign on the right pane to add the directory for the native libs.
This fixed my problem.

Resources