1

So, I wrote my first java application I made a jar file, then I made an .exe file with Launch4j, then I made an installer(with Inno setup compiler) so that every user who downloaded the setup could install the program. The program worked great for every one who had installed java, however those who hadn't installed java got different errors like

"this application requires java runtime environment 1.0.0".

So my question is how can I write my application in java so that any one who wants to download the setup would be able to open the program without errors, I mean how are other programs made for example different games, that don't require any programming systems like java, or python to run smoothly. P.S which programming language should i use, to avoid such kind of errors, for example writing a code in C# or C requires environments like java jdk?

givexa
  • 109
  • 2
  • 10
  • 4
    There is no way for a Java application to run without JRE/JDK. You can package the JRE/JDK with your installer and write instruction to check/install JRE/JDK. – Arvind Kumar Avinash Nov 10 '20 at 20:09
  • Or you can write a server based application in Java and have your users connect remotely. There's no magic way to use Java without at least a runtime environment somewhere. – MarsAtomic Nov 10 '20 at 20:13
  • See https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre. – VGR Nov 11 '20 at 00:48
  • Does this answer your question? [How to deploy a JavaFX 11 Desktop application with a JRE](https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre) – schrieveslaach Nov 12 '20 at 07:33

1 Answers1

2

Shipping the JDK yourself is the only way to do it, these days; the JRE as a concept is obsolete (java8 is the last time it shipped with a JRE).

launch4j has an option to select a directory (relative to where the exe lives) that will be used as java runtime when launching the executable; you can thus ship a JDK alongside.

Looking at the future, starting with java9, you can use jlink to make a 'cut down' version of a JDK with just the bits you need, to make the bundle you ship a bit smaller, and in theory, jlink will give you executables (thus replacing launch4j) but it's all not nearly as smooth as launch4j is last time I checked (which, admittedly, has been a while).

Thus:

  1. Include your own JRE or JDK in the stuff you deploy.
  2. Check the 'use jre' setting in launch4j
  3. Investigate jlink
rzwitserloot
  • 85,357
  • 5
  • 51
  • 72