B4J Tutorial Create Windows native executables (exe files)

Discussion in 'B4J Tutorials' started by Erel, Dec 19, 2013.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    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:

    [​IMG]

    [​IMG]

    4. Click on the Build Wrapper button.

    [​IMG]

    The output will be a standard Windows executable.

    For example:
    [​IMG]

    Another distribution option: http://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: Aug 2, 2015
    Myron, davidt, giga and 11 others like this.
  2. Kiffi

    Kiffi Active Member Licensed User

    Thanks! :)

    Greetings ... Kiffi
     
  3. desof

    desof Well-Known Member Licensed 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= ??
     
  4. Theera

    Theera Well-Known Member Licensed User

    Hi Desof,
    We know that B4J starts using Java1.7
     
  5. electro179

    electro179 Active Member Licensed User

    Hello

    I have a problem

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

    Why ?
     
    Last edited: Dec 23, 2013
    MyominnNaing likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    If it happens when you start the jar file then it is not related to this thread. Please start a new one.
     
  7. electro179

    electro179 Active Member Licensed User

    sorry i'm not understand.
    How to relate to thread ?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    What I meant is that if your app doesn't work when you double click on the jar file then the issue is not related to this forum thread. You should start a new thread in B4J Questions forum.
     
  9. desof

    desof Well-Known Member Licensed 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
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    The main advantage is that you can set a custom file icon.
     
  11. desof

    desof Well-Known Member Licensed User

    ?If I convert a Jar Exe I can run on a Black Berry?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    No. The Exe file will only run on Windows.
     
    jinyistudio likes this.
  13. margret

    margret Well-Known Member Licensed User

    Is there a way to compile the .jar file to a stand alone .exe that does not require a Java runtime environment?
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    I wasn't able to do it with Launch4J. Though according to their documentation it should be possible to bundle the jre.
     
  15. magoandroid

    magoandroid Member Licensed User

    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
     

    Attached Files:

    AlbertDE, Erel and Theera like this.
  16. margret

    margret Well-Known Member Licensed User

    I will try this and report back!

    Thank You ;)
     
  17. margret

    margret Well-Known Member Licensed 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.
     
  18. magoandroid

    magoandroid Member Licensed User

    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
     
  19. margret

    margret Well-Known Member Licensed 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.
     

    Attached Files:

    • test.jpg
      test.jpg
      File size:
      180.7 KB
      Views:
      578
  20. margret

    margret Well-Known Member Licensed 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
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice