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:

hookshy

Well-Known Member
Licensed User
Longtime User
I have fixed the problem by copying code to another httputils2 example ...
Hope I will never met this problem again
 
Last edited:

klakier2121

New Member
Hello, I have 1.8.0 version of java. When i want to create exe file I get: Error: invalid or corrupt file myfile.exe. I am using launch4j. When I am using java -jar myfile.jar command it says the same error. Also added:
#CommandLineArgs:
#MergeLibraries: true
 

klakier2121

New Member
Here:

mlee20kijxu1.png


I have the newest B4J program. My java-version

B4X:
C:\Users\Dom>java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode, sharing)
 
Last edited:

Harris

Expert
Licensed User
Longtime User
I have RDC and my ABM jar files running on a Win 2012 R2 Server.
I would like to make them run as services so when the server reboots, they will start up automatically.

Would I use this tool to create exe's to accomplish this?

Thanks
 

Harris

Expert
Licensed User
Longtime User
You don't need to convert the jar to exe for this. You can run it at startup by running java with the required arguments (java -jar <your jar>).

Would this hold true for batch files as well (such as RunRLC.bat)?
This way, I could see a DOS cmd window with results of each service running when I Remote Desktop into the server in question...

Thanks
 

Harris

Expert
Licensed User
Longtime User
Thanks for very prompt reply. I shall do.

Side Note:

I learn more from the B4X community than Google searches and sourceforge combined (when in context)!
The expansion of B4X has broadened the scope of questions asked, and submitted answers from professionals on the subject matter.

It may take many tries to submit the relevant "Search" text in B4X, but persistence pays off. One needs to re-phrase the search to list relevant results. This I do many times until I exhaust possible phrases. Often I have found the answer in "Similar Threads" when I need to dig deeper.

I always (try) to search before I ask for help. I see where you good folks link a post to the same or similar question.
I only wonder why my search didn't return the same post(s)? (not posed/framed correctly).

Cheers.
 

Sami Zerroog

New Member
Hello every one I completed the steps of converting the .jar file to .exe file.
When I run the .exe file I get the following error msg. Any help please:

The other question I have is how do I include the config.properties file to be wrapped with .jar file??
Please not this is SWING application and I'm using Netbeans IDE


Thank you.

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: oracle/jdbc/pool/OracleDataSource
at hivpapp.DBConnection.DBConnection.getConnection(DBConnection.java:40)
at hivpapp.view.Login.LoginButtonActionPerformed(Login.java:247)
at hivpapp.view.Login.access$300(Login.java:29)
at hivpapp.view.Login$4.actionPerformed(Login.java:106)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 40 more
 
Last edited:

Arnaud

Active Member
Licensed User
Longtime User
Hello,

I have followed the instruction, I have no error that appears, but my file.exe doesn't start...

How know where is the problem?

Thanks.
 

Attachments

  • alfano 6 updater.png
    alfano 6 updater.png
    456.7 KB · Views: 1,007
Status
Not open for further replies.
Top