So after the help From Slaw in the comments I figured out the problem and how to fix it.
My problem was that I was trying to execute a jar file using Java 15.0.1 witch doesn't work well with JavaFX.
At first check that you have Java 8 JDK installed.
And find the virtual machines folder witch in Mac is by default at the library folder under java folder.
Check you have a 1.8 version installed
Then check what is the java version executing the jar by the command:
java -version
Then if it is different then java 8 run the following:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Then run again and check that you are using java 8
java -version
Check that it has changed and run you're jar by using
java -jar JarName.jar
If something is not clear please comment so I will change it.
Hope that I helped you :)
=======================================
Another option:
If you're code is using java 8
if the java -version
is telling you that you are using something different then 1.8.X
On MacOS go to the virtual machine folder at
/Library/Java/JavaVirtualMachines
and keep only the 1.8.X you use so it will be the default.
worked for me as well
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…