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. magoandroid

    magoandroid Member Licensed User

    Hi Margret,
    you're thinking of deploying a single exe file.
    L4J does not do this, because it is not an installer.
    Exe file generated by L4J is a custom zip file.
    By changing the extension from exe in the zip, find the contents of your jar file.
    The exe file is a little bigger (31 kb) of the jar.
    If you want to distribute a single EXE file, you can always just make a zip exploding, a folder that contains the EXE file created with L4J and a jre subdirectory that contains the copy of the JRE that you need.

    Greetings.
    MAgo
     
  2. margret

    margret Well-Known Member Licensed User

    The issue is that the jre is 122meg. The .EXE file is only 312kb. I just wish I had a conditional compiler that would pull in only the required support from the jre and bundle it within the .EXE file. The whole project would most likely be less than a meg or two.
     
  3. BPak

    BPak Active Member Licensed User

    We have programs that do what you wish for. But I do not know how.
    One of the programs is named ProjectX. It is a Java development and one chap has built it as a standalone exe and if I remember correct is about 6MB in download size.
    Maybe it would be worth searching out. ProjectX

    http://www.videohelp.com/tools/ProjectX

    There is a link down the page where the Java is included.

    Hope that may be of some help.
     
  4. giga

    giga Well-Known Member Licensed User

    I have not tried either of these yet, but maybe JSmooth or Excelsior could work for you.

    http://jsmooth.sourceforge.net/

    or this one:

    http://www.excelsiorjet.com/

    Hope that's what your need.
     
    Last edited: Feb 1, 2014
  5. Gaver Powers

    Gaver Powers Member Licensed User

    Not certain if this helps or not...

    http://launch4j.sourceforge.net/docs.html

    Includes a lot of discussion regarding bundling the JRE. (more in the link above)

    Code:
    <jre>
    Required element that groups JRE 
    settings.
    <
    path>, <minVersion>, <maxVersion>
    The <
    path> property is used to specify the absolute or relative path (to the executable) of a bundled JRE, it does not rely on the current directory or <chdir>. Note that this path is not checked until the actual application execution. If you'd like the wrapper to search for a JRE (public or SDK private) use the <minVersion> property, you may also specify the <maxVersion> to prevent it from using higher Java versions. Launch4j will always use the highest version available (in the min/max range of course). If a Sun's JRE is not available or does not satisfy the search criteria, the search will be repeated on IBM runtimes. You can also combine these properties to change the startup process...
    There's also more than 100 hits in their forum on the subject of Bundle JRE

    http://sourceforge.net/p/launch4j/discussion/search/?q=bundle jre

    This one seems pertinent

    http://sourceforge.net/p/launch4j/discussion/332684/thread/356faa8d/?limit=100#a29c

    G
     
    Last edited: Feb 8, 2014
  6. JOTHA

    JOTHA Well-Known Member Licensed User

    Thats my problem.
    When I compile in "Release Mode", the Program starts and works well. I can see that in the Log-file.
    It generates a result in the folder "Objects" named "DataCollectionServer.jar". When I doubleclick on this jar file, an error message apears: "A Java Exception has occured:" (see PNG-File)

    The same error message apears after generating and clicking on the Windows.exe file. What is the problem solution?
     

    Attached Files:

  7. Erel

    Erel Administrator Staff Member Licensed User

    Try to run it from the command line with java -jar <your jar name>
    You will see the error message.

    Also run java -version

    My guess is that the default java is an older version of java.
     
    JOTHA likes this.
  8. margret

    margret Well-Known Member Licensed User

    Running java -version from the CMD prompt displays:

    java version "1.7.0_45"
    Jave SE Runtime (build 1.7.0_45-b18)
    Java HotSpot Client VM (build 24.45-b08, mixed mode, sharing)
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Sorry for the confusion. My post was directed to @JOTHA.
     
  10. JOTHA

    JOTHA Well-Known Member Licensed User

    Hello Erel,
    thank you for your help!
    I did what you said.
    A DOS-Window apeared just for some milliseconds and I couldn't read the information.
    Do you know how to stop the window to remove from the screen?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    You should press on the start button and write cmd.exe. It will take you to the "dos console".
     
  12. JOTHA

    JOTHA Well-Known Member Licensed User

    oops you where faster ...

    The solution is: Writing "cmd" into the command line and click Enter. A DOS-Window apears and you can see everything.

    But there's no error message everything seems OK (see attached file)?
     

    Attached Files:

  13. Erel

    Erel Administrator Staff Member Licensed User

    You should run java -jar <your jar>
     
  14. johnerikson

    johnerikson Active Member Licensed User

    I have the same problem to start .jar file wrapped to .exe.
    You can see the error message in attached file below.
    What can cause this error?
     

    Attached Files:

  15. Erel

    Erel Administrator Staff Member Licensed User

    Have you set #MergeLibraries to True in the IDE?
     
  16. johnerikson

    johnerikson Active Member Licensed User

    No, but now, and it works well!

    Anyway, I am very impressed by the whole B4x-concept.
    Many thanks!
     
  17. luke2012

    luke2012 Well-Known Member Licensed User

    Hi @Erel.
    There are some additional settings to do in launch4j in order to start a web socket server ?
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    No. The same steps should work.
     
    luke2012 likes this.
  19. hookshy

    hookshy Well-Known Member Licensed User

    I did try to make exe ... I did succeded to the point where i must open the file ...
    I get the error invalid or corupt jar file

    I can not run the original jar file on windows ...I have to make it application .exe?
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    If Java is installed correctly then you should be able to double click on the jar file that is generated when you run your app in Release mode.
     
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