B4J Question B4JPackager11 creates a small exe that does not run standalone

Didier9

Well-Known Member
Licensed User
Longtime User
Using B4JPackager11 version 1.02 to create a standalone exe. The process completes with no error but the resulting exe is very small and only runs on the machine that created it. It does not run on another machine configured similarly (Windows 7, corporate environment, Openjdk-11.0.1 with javafx, B4J v7.31)
Waiting for debugger to connect...
Program started.
B4JPackager11 Version 1.02
Looking for javafx modules under C:\Java\jdk-11.0.1\bin\..\javafx\javafx-jmods
Looking for javafx fibraries under C:\Java\jdk-11.0.1\bin\..\javafx\lib
InputJar: C:\Users\jugesd\Documents\B4J Projects\CAN232_B4J\dev\Objects\result.jar
Running: C:\Users\jugesd\DOCUME~1\B4JPRO~1\B4JPAC~1\Objects\temp\FindDosPath.exe
Running: C:\Java\jdk-11.0.1\bin\jar
Package name: b4j.can232
Running: C:\Java\jdk-11.0.1\bin\jdeps
.
.
.
.
.
Explicitly excluded modules: [javafx.web]
Included modules: [java.base, java.desktop, java.logging, java.xml, javafx.base, javafx.controls, javafx.fxml, javafx.graphics, javafx.media, javafx.swing, java.scripting, jdk.unsupported, java.datatransfer, jdk.unsupported.desktop, jdk.jsobject, jdk.xml.dom]
Running: C:\Java\jdk-11.0.1\bin\javac
.
Running: C:\Java\jdk-11.0.1\bin\jar
.
Running: C:\Java\jdk-11.0.1\bin\jlink
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Running: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe
.
Running: explorer.exe

Note the "Looking for..." statements have been added by me, that's the only change I made from the B4JPackager11 v1.02 distribution.
 

Attachments

  • exe size.png
    exe size.png
    138.4 KB · Views: 243
  • jar size.png
    jar size.png
    132.8 KB · Views: 195
  • project size.png
    project size.png
    138.1 KB · Views: 193

Erel

B4X founder
Staff member
Licensed User
Longtime User
Everything looks good. What happens when you double click on the exe file (in that folder)?

Edit: explanation - the exe file will not run without the other folders. You have two options:

1. Create a zip file with the files and folders and distribute it.
2. Create an installer using Inno Setup. There should be a file named InstallerScript-Template.iss in that folder with the installer script.
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
May not be related/have nothing to do with this: Do you by chance have #MergeLibraries set to False?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The exe file in the build folder is expected to be small. It is just a launcher that starts the embedded Java with the program jar. You can see it in the bin folder.

I've answered @Didier9 in the previous thread and told him that the exe file should be large. I was talking about the installer exe file. The one that produced with Inno Setup.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Everything looks good. What happens when you double click on the exe file (in that folder)?

Edit: explanation - the exe file will not run without the other folders. You have two options:

1. Create a zip file with the files and folders and distribute it.
2. Create an installer using Inno Setup. There should be a file named InstallerScript-Template.iss in that folder with the installer script.

If I run it on the computer that created it, exactly from the location where B4JPackager11 put it, the program runs.
If I move the exe to another location on the same computer, it does not run. I get the two messages attached (one is by running the exe, the other by running the debug batch file).
I copied the exe to another computer (same Win7 64 bits, same Openjdk-11.0.1, same B4J installation but I did not copy the other folders), I get the two messages attached.
It makes no difference if I have the exe by itself or if I copy all the folders created by B4JPackager11 in the same folder (as shown in the "exe size" screenshot in the first message).
 

Attachments

  • Debug Error msg.png
    Debug Error msg.png
    33.4 KB · Views: 194
  • Error msg.png
    Error msg.png
    22.1 KB · Views: 174
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
The exe file in the build folder is expected to be small. It is just a launcher that starts the embedded Java with the program jar. You can see it in the bin folder.

I've answered @Didier9 in the previous thread and told him that the exe file should be large. I was talking about the installer exe file. The one that produced with Inno Setup.

I do not see a program jar in any of the folders created by B4JPackager11. There are ony 2 jar files, javafx-swt.jar and jrt-fs.jar in the lib folder.

However, if I copy the entirety of the temp folder to another location on the same computer, the program starts (the temp folder has a jar.jar file that is ~3MB). So I thought I had it...

But if I copy the entire temp folder to another computer (same OS,, same jdk, same B4J installation) and try to run the exe from there, I get the same error as above (cannot find the main class)
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
There are three stages of producing a java11 program for use on another machine.

1, Write the code and debug in the IDE until you are satisfied it is correct.

2, Use the B4JPackager11 to produce modularised jar.

3, Use the inno Setup program, using the InstallerScript-Template.iss in the temp folder of the B4JPackeger11 folder, to produce a standalone installer with the required Java runtime in it.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I copied the entire temp folder to the second computer (same OS, same B4J installation which runs the software fine from under B4J in debug or release mode) and tried to run the exe.
Same error (cannot find main class)

I have attached the project. If you get the main window to load from a folder different from where it was created without complaining that it cannot find the main class, I will consider that success. Extra brownie points if you get it to run on a different computer from where the exe was built :)

For now, I have to deliver something for internal use and after working two days to develop the software which works under B4J (not finished but usable for what I need to do now), I have spent 5 work days and a week end trying to get the exe to run on a second machine with nothing to show for it.

Since the program runs fine under B4J, I am going to instruct the test engineer to just start the program from B4J. It's ugly but it won't be the first time and I can get him off my back :)
Main advantage of B4J right there: I can install as many copies of B4J as I need. Thanks a lot again Erel for making this free!
Then hopefully when I figure out where I went wrong, I will fix it.

To summarize:

I am working on 3 machines, a Win10 computer at home and two Win 7 at work. All 64 bits. All have jdk11 from Erel's link, B4J 7.31 and B4JPackager11 v1.02. The home machine and the main work machine can produce an exe with B4JPackager11 which runs on the computer where it was created as long as I do not move the folder. The second work machine does not run the exe (that was produced by B4JPackager11 on THAT machine) at all even though the program runs from within B4J, and B4JPackager11 does not produce any error code. The error is always Cannot find main class.

I did try to run the jar file directly (on my main work machine) using this command (that would be acceptable in my environment):
B4X:
C:\Java\jdk-11.0.1\bin\java -jar .\result.jar
and I got:
Error: JavaFX runtime components are missing, and are required to run this application
Not sure what I need to do to install the JavaFX runtime components...

I do not need an installer at this time, even though as I am planning to extend the use of B4J, I will need to be able to build a setup.exe at some point. Some of our test software ends up on customer's equipment for test and troubleshooting so a streamlined installation process is desirable.

Thank you everybody for trying to help.
 

Attachments

  • forum copy.zip
    17.4 KB · Views: 153
Upvote 0

OliverA

Expert
Licensed User
Longtime User
The file that works for me is the run.exe file in the build directory. I'm using it on Windows 10 (Pro, 64bit, build 1809) and when using Windows Explorer to launch the executable, I do get a "Search for app in the Store? You need to install an app for this task. Would you like to search fo one in the Store?" message. I just answer no and your application starts. The run_debug.bat file also works (with the same message).

BTW, when I run the run.exe and the run_debug.bat file from the command line, everything just works.

Looks like I have something weird happening in Windows Explorer. After starting an application (I tried another program), when I go to File->Help->About Windows, it starts that program instead of bringing up the About information. This is in effect until I close out Windows Explorer and open it back up. Odd... and off topic (sorry)
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Yes, that is the file I am trying to run, and which runs on two of the 3 machines I have tried (one Win 10 and 2 Win 7).

I am starting to believe it is some different configuration on that particular computer. My two work machines are supposed to be configured the same (Win 7 64 bit, OpenJDK 11.0.1 and normally what should be the same package of corporate security patches, Bit9 and other "utilities" of dubious utility) but I was looking at the environment variables on the two Win 7 machines and they have different sets of variables.

The machine that does not run the exe did not have JAVA_HOME or JRE_HOME. I added these variables making sure they pointed to the right place but it did not help. Some of the corporate payload includes java programs so these machines also have the official Java JRE installed, actually several versions of it because as we all know, "Java write once runs everywhere" is a bunch of b**l, so each machine has 3 or 4 sets of Oracle java versions to support the various applications.

Thanks for trying!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You don't need any other version of Java installed. It uses the embedded Java runtime to run your app.
If there is one specific computer that it doesn't work then you need to check why it doesn't work. This thread is too long for me to help. You should start a new thread with only the relevant information. Start with running run_debug.bat and post the output.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I understand I do not need any other version installed. The question is could it cause a problem if I have other versions installed?

Anyhow, I will start a new thread if needed when I have more information. For now, I am going to run from the B4J IDE on that machine and I am going to try to create a setup.exe executable with innosetup on the machines that run the exe.
Thank you
 
Upvote 0
Top