Ok, another newbie question. I've got my overall project working, but I can't get it to run outside the B4J development environment. I created a simple do-nothing project with the same results and have attached it here. So what am I doing incorrectly?
I changed the Debug/Release combo to Release, Clicked on Run and it created a .jar file. I right-click on the .jar and tell it to open with Java, then nothing.
I'm suspecting it has something to do with the java version.
My JDK is version 11.0.1
My JRE is version 1.8.0_201
Ok, quick followup. I went to cmd prompt and tried from there using both java versions.
Using the JDK Java
D:\B4J_Dev\Projects\Blah\Objects>C:\Java\jdk-11.0.1\bin\java -jar blah.jar
Error: JavaFX runtime components are missing, and are required to run this application
Using the JRE Java
D:\B4J_Dev\Projects\Blah\Objects>C:\java\jre-1.8.0_201\bin\java -jar blah.jar
Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.UnsupportedClassVersionError: b4j/example/main has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
etc.etc.etc.
You have two options:
1. Compile with Java 8. This will create an executable jar.
2. Compile with Java 11 and use B4JPackager11 to create an installer.
You have two options:
1. Compile with Java 8. This will create an executable jar.
2. Compile with Java 11 and use B4JPackager11 to create an installer.
No need to uninstall anything. You can have multiple versions of Java installed. Just make sure to configure B4J to use the one you want (Tools - Configure Paths).
@AKJammer There's currently two versions of B4Jpackager (for Java 8) and the newer B4Jpackager11 (for Java 11+). Use Launch4J to create and prepare the exe then install Inno setup and use any of the B4Jpackagers available. If the PATH variable is not correctly set you can use the guide to manually create an installer with Inno setup.
Sorry, I've been out of town for the past couple weeks. Back to this..
I upgraded my OpenJDK from 11.0.1 to 11.0.3 along with the Open Jfx (11.0.2) and Jmods (11.0.2).
I pulled down B4jPackager11 and ran it against Blah. Worked!!
Ran it against my main program. Worked!!
Copied the .exe file to a different computer. Nothing... So obviously any computer I try to run this on either has to have something else installed, I'm assuming Java, or I need to wrap the .exe into something that has everything it needs. Is this where Launch4J would come in?
@AKJammer As far as I recall Launch4J is used to create an .exe file and associate an icon to it, to be used on Windows. Run Launch4J on Mac to create a Mac installation bundle, so you only want to use it for this purpose. Regarding to Erel's advice the B4Jpackager and B4Jpackager11 tool should be enough to create an installer.
You might want to add in the correct Java RNE folder just in case, like the old Windows games that had a DirectX and OpenGL subfolder to assist in the installation process.
Ah, ok. I tried to just move the .exe file over. I needed to move the entire build directory over since it contains all the libraries and such. That'll work, I can build an install package from this point.
Thanks!
I think I got the advice to use Launch4J to be able to create an .exe file with attached icon just to get the shortcut on the Windows desktop, at least it solved the problem.
just my two cents until I learn the proper ways
I'm opening again this thread because I'm having the same/or very similar issue but:
1. I need to use Java 8 due to some compatilibites issues with external devices. I cannot use Java 11.
2. In Release mode, when I compile and execute the program from B4J, it works. But, when I try to execute it from the executable JAR file created in the Objects folder, i'm getting the error that you can find in the image attached.