B4J Question [The impossible question] using B4J to compile a Windows DLL

Alessandro71

Well-Known Member
Licensed User
Longtime User
I have a very big chunk of B4J code (data processing routines, no graphics and/or interactive code) a customer wants to use as a DLL in his own Windows application.
Is there any way to use B4J code as module in external applications?
As a fallback plan, I'm thinking about building a standalone exe that can be called with parameters and returning data in JSON format, to be processed by the calling application.
 

Sandman

Expert
Licensed User
Longtime User
You could also be brave and try to google for how to turn a java jar to a dll. Regardless, your fallback option should work nicely if the dll thing wasn't a hard requirement.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
According to ChatGPT there no simple way. It gives a couple of suggestions, but it's clear they contain pain. My guy feeling is that nothing good will come from this strategy.

However, depending on what the java code does, there's another option. Theoretically you could make a very thin dll that just calls your jar with whatever input makes sense, and blindly returns whatever the jar returned. The app using the dll would have no clue that the dll is razor thin. And considering you thought json was fine, I can't see any issues with this method either.

(If you go this route, why not make the dll slightly configurable, either via an .ini or the registry, so that it has no clue what to call by itself and needs to look in the config. That way you can reuse it for lots of projects and only need to adjust some parameters in the config - no actual change or recompilation needed.)
 
Upvote 0

Pablo Torres

Active Member
Licensed User
Longtime User
I have a very big chunk of B4J code (data processing routines, no graphics and/or interactive code) a customer wants to use as a DLL in his own Windows application.
Is there any way to use B4J code as module in external applications?
As a fallback plan, I'm thinking about building a standalone exe that can be called with parameters and returning data in JSON format, to be processed by the calling application.

you can create an exe from a b4j console program that works as a service (listen in an http port and answer) and make that exe run as windows service with nssm
 
Upvote 0

vmag

Active Member
I have had a positive and highly successful experience using my application by third-party users with their own applications...
The program just runs in the background and analyzes a specific network resource. When text files with instructions appear there, the program executes these instructions and deletes the files.
Users only need to provide a description of the files with instructions. Some of them modified their programs to create files with instructions, and some simply filled out a template and copied the file to a shared folder, but everyone was happy...
That was 20 years ago…
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
I have had a positive and highly successful experience using my application by third-party users with their own applications...
The program just runs in the background and analyzes a specific network resource. When text files with instructions appear there, the program executes these instructions and deletes the files.
Users only need to provide a description of the files with instructions. Some of them modified their programs to create files with instructions, and some simply filled out a template and copied the file to a shared folder, but everyone was happy...
That was 20 years ago…
A Windows service, just like Pablo suggested?
 
Upvote 0

vmag

Active Member
No, an ordinary exe file in startup, just a tray icon that analyzes the contents of the folder and executes the instructions that appear in it, there is no direct interaction with the exe file itself. In those early days, making a service for win95 was problematic. But the idea itself looked like a service.
for example, there is a program that centrally print receipt or photos that appear in a network folder and it doesn't matter how they appeared there or whose they are...
These can be exchange rate templates or securities.
 
Last edited:
Upvote 0
Top