B4J Question StandAlone EXE small in size... with web-downloader/installer [SOLVED]

Magma

Expert
Licensed User
Longtime User
Hi there...

[Here the solution found !!!]

creating a standalone exe with b4jpackager can be a big file... sometimes is little difficult to include in small size usb-sticks or want to have a progressive download bar that will not using internet download manager for many reasons...

Check for example trial of kaspsersky i/s - have a small package (2-3mb) that downloads a bigger (300mb) with a progressive-bar...

[i need a utility]

I know it's difficult to have a java-app running without a java-runtime on pc... but anyone knows a utility that creates an exe (with no need of libs,dlls->portable) -> that will already set (before compile it - some way) a url and an image, title of our app and progressive download it from.. our server/google drive for example and then run it... ???

anyone ?

Thanks in advance...
 
Last edited:

amorosik

Expert
Licensed User
The problem is common to all languages that somehow use a p-code that is executed on-the-fly by a set of functions in a 'run-time' library
And the execution of java code is based precisely on its interpretation by a library and transformation into x86 code (or other cpu level code), same thing as the Microsoft languages, dot net environment
So using B4J I don't think we can improve it
But if the goal is to create a downloader that does not have dependencies, then you could consider using a work environment that creates exe without dependencies, for example Lazarus is free and creates exe even from 2 Mbyte
I would also be very interested in creating a system that, in addition to downloading a file via http / ftp / smb and running it, would allow you to check the version and allow you to update an existing procedure.
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
@amarosik i totally agree with your opinion... actually this isn't a problem that we meet now... always exist !

Lazarus... is something like pascal and c++ nice... but it is a tool that needs time to learn it...

searching the web found this solution:
https://nsis.sourceforge.io/Main_Page

it seems that have compiler too with simple scripts... it has features to download and extract a compressed file... but i am not so impressed... with interface and the result....

any other idea...?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
....JUST found the best utility...

it is free... not all features ofcourse... but is a start !!!

https://www.actualinstaller.com/

It creates a Standalone EXE !!! - all the b4j standalone folder packed into -> selecting the main exe and voila... simple and fast creating the package...

The download function must be paid first ... :-(
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check for example trial of kaspsersky i/s - have a small package (2-3mb) that downloads a bigger (300mb) with a progressive-bar...
There is a difference between 300mb and 30mb - the size of a zipped B4J package (without WebView). I wouldn't invest too much efforts in this. It will also add another possible point of failure.
 
Upvote 0

amorosik

Expert
Licensed User
Have you already tried InnoSetup too?
Allows you to download external files and creates a single executable with no dependencies to launch
It is also widely used and there are several examples and support
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
@amorosik .. yes it's a good solution... but downloading a package of files... and extracting into installation seems little difficult... (as i can understand) there isn't native extraction of zip files...

There is an example downloading file by file... but not extracting into the Installer..
 
Upvote 0

amorosik

Expert
Licensed User
@amorosik .. yes it's a good solution... but downloading a package of files... and extracting into installation seems little difficult... (as i can understand) there isn't native extraction of zip files...

There is an example downloading file by file... but not extracting into the Installer..

InnoSetup is a very mature and complete installation system
Extracting files from a zip is a very simple operation that can be performed from the RUN section
This is an answer take from StackOverflow forum

----------------------------------------------------------------------------------------------------------
You can use an external command line tool for unzipping your archive, see here for example. Put it in your [Files] section:
[Files]
Source: "UNZIP.EXE"; DestDir: "{tmp}"; Flags: deleteafterinstall

Then call it in your [Run] section, like this:
[Run]
Filename: "{tmp}\UNZIP.EXE"; Parameters: "{tmp}\ZipFile.ZIP -d C:\TargetDir"

(You'll probably want to take your target directory from a script variable, so there is some more work that needs to be done)
----------------------------------------------------------------------------------------------------------
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Yes.. i know... it doesn't do it natively.. so must hide the cmd prompt window (easy)... and must include license for unzip tool :)

+There is no native check what will be the result of unzipping (if will have problem or something)

but.. is a simple solution / hope having a native solution for it... i am searching little more to find something... thanks again !
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
SOLVED

...after a lot of searching... found a middle way to use Innosetup...

Result: Standalone 2MB ----> Installs... 100MB !

I am posting here an example to help other users...


What the developer need...

ofcourse latest InnoSetup (6.1.2+)

attention: At example i have uploaded the build folder (created by standalone exe b4j) an App call it GemInfo (not doing anything just site automate... just tabs... and typing...) a simple example that sizing about 100MB when extracted - uploaded as 7z compressed file to my server. (www.magma.gr/downloads/latest.7z)

1) Create an empty folder that will used for creator setup folder (at the example is: D:\B4J\inno-setup-webdownload\)

2) Download 7z (7za) command line tool from here... (just grab from it the 7za.exe) and copy it -> to the creator setup folder (for ex. D:\B4J\inno-setup-webdownload\)

3) Download the setupwebdownloader.iss (in zip file attached) and put it to the creator setup folder (for ex. D:\B4J\inno-setup-webdownload\)

4) Open and edit the setupwebdownloader.iss edit the folders if different... and if you wanna make your example edit the url and the 7z file (ofcourse need to upload your 7z file to your server-url-folder)

5) Just - Build/Compile and go menu Build/Open Output Folder ---> that's it... a small file to give at your customers!!!


Hidden runs the 7za and extract the 7z downloaded from a url... then delete's 7z and 7za.exe from tmp....
Also at uninstall completely delete the folder with all the files !

I think is a good solution...

If someone want can include .net framework installer (with downloading) and try to install it... just add these commands (someway you can check and .net version)

B4X:
...
[Run]
Filename: {tmp}\7za.exe; Parameters: "x ""{tmp}\latest.7z"" -o""{app}\"" * -r -aoa"; Flags: runhidden runascurrentuser;
Filename: {tmp}\ndp48-web.exe; Flags: runhidden runascurrentuser;
....
function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpReady then begin
    DownloadPage.Clear;
    DownloadPage.Add('https://www.magma.gr/downloads/latest.7z', 'latest.7z', '');
    DownloadPage.Add('https://go.microsoft.com/fwlink/?LinkId=2085155', 'ndp48-web.exe', '');
...
 

Attachments

  • setupwebdownloader.zip
    1.3 KB · Views: 225
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
Here how to check the .net version...
at [ code ] add this function...

actually if no specific (4.8 in example) framework and need to install gives... True
if has framework gives False..

B4X:
function FrameworkIsNotInstalled: Boolean;
begin
  Result := not IsDotNetInstalled(net48, 0); //Returns True if .NET Framework version as 4.8
end;

and at run you can add this:
B4X:
[Run]
Filename: {tmp}\ndp48-web.exe; Parameters: "/q /noreboot"; Flags: runhidden runascurrentuser; Check: FrameworkIsNotInstalled;

also at code at function NextButtonClick you must add:
B4X:
if FrameworkIsNotInstalled then DownloadPage.Add('https://go.microsoft.com/fwlink/?LinkId=2085155', 'ndp48-web.exe', '');
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Thanks.
I think this is useful if someone downloaded my setup file and later change his mind not to proceed with the install or accidentally download redundant copies of the same installer. This installer will taking up harddisk space. I feel annoyed to huge size software installer. This also saving up space in my server to store multiple archived version of installer.
 
Upvote 0
Top