B4J Question Use jar file to open Windows 10 default files

lrw65

New Member
Licensed User
I am writing an image viewer in B4J which I would like to use as the default app to open images (jpg etc). When I try to associate jpg images with my jar file, Windows shows a message that this app can't run on your PC. I can run the jar file and it will load and display images. But it can't be used as the default app. Can it be? I have looked at a programme called launch4j, but I haven't tried it. Just for a giggle I installed my very old VB6 and created an app that would do what I want. But the poor thing looks soooo dated!
Lee.
 

Didier9

Well-Known Member
Licensed User
Longtime User
The jar file does not run by itself, it is a recognized type by Windows and it calls the Java Runtime so you can't associate it with anything.
There are packagers that will encapsulate your jar file into an exe which you could then use as the default executable for a given file type.
Look for Packager on the forum.

Personally I had problems with the Packager but better luck with http://launch4j.sourceforge.net/
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Lanuch4J works ok. It can pass arguments.

I like it too but I have not managed to make it work with OpenJDK version 11. Launch4J expects to be pointed to a JRE and there is no JRE for OpenJDK 11.

Another thing I like is that it seems to resolve a strange issue. I reported before having great difficulties running the jar file produced by B4J on my corporate laptops. The IDE runs fine, the project runs fine in Debug mode but it does not run in release, something about missing the Main class file. I tried multiple corporate laptops and all do it while several personal laptops do not have problems (mix of Windows 7 and 10, 32 and 64 bits).

I have been using Launch4J at home for a little while just fine but just today, for the heck of it and without any hope, I installed Launch4J on the corporate machine (pointed it to the Oracle Java 1.8.xxx jre) and the exe runs fine!

Success, and a very large thorn off my side.

Previous attempts with the Packager and Packager11 tools did not work at all on the corporate machines.
 
Upvote 0

lrw65

New Member
Licensed User
Thanks for the replies, I think I knew that Launch4J would be the way to go. I will try it when I have the time.
 
Upvote 0
Top