B4J Question B4J Release Mode - How to run?

Status
Not open for further replies.

AKJammer

Active Member
Licensed User
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

I had to have a JRE because the Launch4J app I was trying to use has a bug: https://sourceforge.net/p/launch4j/bugs/177/ that requires a JRE path.

Any ideas on how to troubleshoot this? Or how to fix?

Thanks,
Jim
 

Attachments

  • Blah.jar
    363.6 KB · Views: 231
  • Blah.zip
    1.9 KB · Views: 251

AKJammer

Active Member
Licensed User
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.
 
Upvote 0

AKJammer

Active Member
Licensed User
You compiled your app with Java 9 (=53).

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.

Ah, ok. I’ll uninstall the current JDK and JRE and put 11 on.
Thanks
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@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.
:)
 
Upvote 0

AKJammer

Active Member
Licensed User
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?
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@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.
 
Upvote 0

AKJammer

Active Member
Licensed User
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!
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
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 :)
 
Upvote 0

enrique1

Member
Licensed User
Longtime User
Hi all,

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.

Thank you for your support.
 

Attachments

  • Error Executing.png
    Error Executing.png
    31.2 KB · Views: 238
Upvote 0
Status
Not open for further replies.
Top