Embed both JAR and JRE into .exe

I can build a Windows EXE with the JAR and JRE in the “app” and “runtime” folders respectively. Is there any way to embed both of these into the EXE so they’re not visible?

do you want to have your jars and embedded JRE as a single file?

I don’t know if it is possible, however I suspect you are trying to solve a problem that don’t exist (what’s wrong with the app and runtime folders?)

Elaborating on what @Pesegato stated, it’s rare to find games that bundle everything (game code, assets, etc…) all in a magical Game.exe. You should instead bundle it in an installer so it installs the game and makes a link of the .exe file to the Desktop, like 90% of the games.

https://www.excelsiorjet.com/

Excelsior compiles your java code into native binary app. In the result you don’t need to bundle JVM as separate files.

I was under the assumption that you can do it with jME SDK.

Hey have you ever tried it out? That performance gain and startup time they’re talking about sounds great, but is it noticable?

Edit: And it’s a $3K license hah, nevermind that.

1 Like

Per developer.

Per minute used.

4 Likes

lol

but yeah even as a solo dev (well… especially as a solo dev) there’s no way I’m shelling out 3K for something that’s a convenience at best.

It’s not a critical issue, I can just distribute the JAR and JRE alongside the EXE, but I’d much rather have it all in a single file. I read that Launch4J could supposedly do this (although I didn’t have any luck getting it working on my own) so I was hoping there was a painless way to do it built into the JME SDK.

luanch4j will make an EXE that is the jar for your app but I’m 99% sure that the JRE would still be sitting beside it.

This is kind of what installers are for. One file that you run that puts all of the real stuff in the right place. You can also look at things like getdown (GitHub - threerings/getdown: Download, Install, Update) which will automatically download the latest parts. Just in case you want to update that one texture without having them download the whole 100 meg installer file again.

3 Likes

Wow, thanks @pspeed! I wasn’t aware of that tool. Thank you :slight_smile:

Thanks @pspeed.

Never tested it, but I have a standard license :wink:

It is possible to buy a license for 10$ - I mean full standard license. Sometimes they make a sale and donate all of their income to charity.

I hate to keep jogging on about minecraft, but it has a c++ installer and downloads its own jre, and in that time gets any additional dependencies or updates. Its about the only way really. Qt is a lovely little piece of kit btw.

I think mc actually uses somekind of js or something to render the front end installer. I know nothing about that particular setup but i guess its just a gui choice.

1 Like

Answering a question without a context is often stupid.
What do you want to achieve? Do you want to “protect” your code by that?

Bundling all into an exe has several severe problems like:

  • Patching stuff is harder
    (Imagine Users want to mod or even fix a bug in 2030, when you don’t support the game anymore. They could just use Winrar on the jar file for drop in)
  • You have no chance to prevent someone semi-knowledged from getting around that
    (If you build all into an exe, they will most likely still extract their contents to a temp dir or something and launch the jre there, so one could eavesdrop. If not, the jar file definitely has to be unencrypted in the program memory)
  • Things like ThreeRings’ GetDown will be less nice
    (They operate on a per-file basis instead of patching with BSDIFF or something, which is a huge downside I think for GetDown. If you only have one file you don’t save any bandwidth at all. JME Projects in general won’t profit that much, because if you change an asset the whole gigabytes of asset.jar have to be reloaded)
  • Performance Slowdown in loading time (Depending on the Storage you can read multiple files at once, but with an .exe mostlikely even compressed or encrypted, all the data will be singlethreaded and passed through the cpu first, really bad, and you will still be hacked).

That being said, what you could do is launch4j/the SDK as is and then use 7zip SFX (or other SFX), which are nothing more than a .zip packed into an exe stub which does the unpacking (however it will, as said, unpack the .jar and jre to some folder prior to launching them, but you only have to share one file).

Note that on Linux it’s a one-liner to extract your data from these exes and this is good:
Imagine you don’t support linux per-se. If you don’t share an exe, but maybe a zip/rar, these guys can try to launch the game anyway, by invoking java -jar YourGame.jar.

The best option is to build an exe which contains game’s jar and starts JVM by JNI, like latest Launch4j does. It is important to not show java.exe in process manager, for unknown reason players are scared of Java. JVM should be bundled, because the best version of Java is the one used during development, so don’t even look if player have one installed on his machine.
Obfuscating the code is enough - noobs will not understand anything, someone who is smart enough to find himself in such code does not really need it, he will not copy-paste it into his own project.

1 Like

The reason that people are scared of java.exe is because people believe java is slow and insecure. (what people mean with insecure is beyond me. Java is a programming language, if it is secure you can probably not code games into it.)

Another reason may be that they don’t know how computers work and how to “read” the process manager and thus freak out every time an “unknown” process appears.

That does mean though that you are right and its probably a good idea to make it as hard as possible for people to figure out your game has anything to do with java. Its stupid.

Java WAS slow in 1995, when there was no JIT etc.
Java CAN be insecure IF you use an older version AND your code exposes some vulnerability.

But non-Java games are insecure as well… simply nobody cares. Oh, and don’t let me get started on the DRM rootkits that are installed without the user knowing, which are way more likely to cause actual harm to users…

But back to the point.
As others pointed out, bundling everything on a .exe has many disadvantages.
Obfuscation and assets protection are m00t points.

Most importantly, we are in 2017. Installers are old school, today there is steam that takes cares of everything and you don’t even bother clicking on the executable, as you run stuff from the steam client. Other “app stores” works the same way.
If I want to distribute stuff outside of the market, I just zip everything as I personally prefer it over installer…

1 Like

Hi,

maybe I’m wrong, but I think you’re not allowed to do that. Oracle’s JRE is free to use, but if you distribute it repacked in your own software, you need to pay some licence. Most of the time, they don’t say anything, but they can. This is why popular software don’t pack the JRE.