B4J Tutorial Create Windows native executables (exe files)

Status
Not open for further replies.
This tutorial is no longer relevant. Use B4JPackager11: B4JPackager11 - the simplest way to distribute UI apps
When you compile in Release mode the complete app is packed as an executable jar file.

You can distribute this jar file and run it on Windows, Mac or Linux.

However there are cases where you want to convert this jar file to a native executable. For example if you want to set a custom icon.

You can use a free tool named Launch4j to convert the jar file to a native Windows executable.

1. Download Launch4j: http://sourceforge.net/projects/launch4j/files/launch4j-3/
2. Compile your app in Release mode.
3. Set the icon and other required parameters:

SS-2013-12-19_15.34.01.png


SS-2013-12-19_15.34.24.png


4. Click on the Build Wrapper button.

SS-2014-01-21_09.43.59.png


The output will be a standard Windows executable.

For example:
SS-2013-12-19_15.36.28.png


Another distribution option: https://www.b4x.com/android/forum/threads/ui-apps-packaging-self-contained-installers.56854/
B4J Packager will create a single installer file that includes an embedded Java Runtime.
 
Last edited:

desof

Well-Known Member
Licensed User
Longtime User
No me funciona dice que la version no es válida en JRE ...??

I work does not say that the version is not valid in JRE ...?

MIN = ??
MAX= ??
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Desof,
We know that B4J starts using Java1.7
 

electro179

Active Member
Licensed User
Longtime User
Hello

I have a problem

When I launch the exe or jar file , my program runs and closes immediately .

Why ?
 
Last edited:

desof

Well-Known Member
Licensed User
Longtime User
Pardon my ignorance but I fail to understand very well that advantages can give me convert a. Into a jar. Exe?
Create a. Exe I guarantee that only run on windows?
Create a. Exe I guarantee that other agencies are not required to work the same
 

magoandroid

Member
Licensed User
Longtime User
Is there a way to compile the .jar file to a stand alone .exe that does not require a Java runtime environment?

Hi Margret,
you can do it.
I did it using Launch4J-3.1.0-beta2-win32 and I bundle the jre.

Verified on local PC with XP, W7 without JVM, it works fine.

A little example.

Created a folder with subfolders (BIN, JRE, CFG).
BIN (My application with the .exe and the .jar and all the other stuff)
JRE (The folder I'm using is just a copy & paste from the jre folder installed on a Windows system).
CFG (To save the user configuration, but it's not needed).

Is that the trick here is not the path to the java.exe file.
The path to the jre is related to the position of the .exe and It should point to one folder before the java.exe file.

The attached picture should help.

Greetings.
MAgo
 

Attachments

  • Example  L4j.png
    Example L4j.png
    96.4 KB · Views: 2,630

magoandroid

Member
Licensed User
Longtime User
I have tried this many ways and can not get it to work. It wraps the file fine and runs on any other pc that has Java 1.7. However, if I put it on another machine that does not have a Java runtime, it fails. Can you provide any more info? It would really be great to get this working.

Hi Margret,
I L4J encapsulated using JRE 1.7 in the following situations:
1) PC (Local) with a JRE installed (works fine)

2) PC (Local) without JRE installed (works fine)

3) PC (network with user permission) with an old JRE installed (version 1.5), which can not be updated.
The exe file is in a folder on the server that requires JRE 1.7 (works fine).

You can make your layout a simple example to try.

Greetings.
MAgo
 

margret

Well-Known Member
Licensed User
Longtime User
I see in L4J, under the error messages, that you should be able to bundle the Java runtime. The issue is that when I wrap the project, the EXE is only about 10k larger and does not include the JRE. I did it just like your insturctions and your screen shot. Did you try the sample you did on a system with no Internet connection? Even if the machines didn't have Java installed, maybe it was getting it over the web. The unit I tested on was XP with no Java runtime and no Internet connection.
 

Attachments

  • test.jpg
    test.jpg
    180.7 KB · Views: 1,550

margret

Well-Known Member
Licensed User
Longtime User
I have no issues with Launch4j. I have added splash screens, app icon, etc. All works just as it should. However, I can not get a stand alone .EXE file to work that does not require a runtime install of Java. There should be a way to wrap this so the needed files are internal to the .EXE file. If anyone can give any input on this, it would be great. I need an .EXE that will run on any Windows system even if they have no Java runtime or Internet connection. Anyone got this working??

Thanks,

Margret
 
Status
Not open for further replies.
Top