I struggle with the problem of distributing applications written in java to computers that do not have java installed.

Unfortunately, exe applications, no matter how I make them, turn out to be extremely unstable:

  • IntelliJ IDEA ( exe from the bundle resulting artifact even does not always start with me )
  • launch4j ( javaw.exe flashes in the processes for only a second; jre is in the folder with the application, this is indicated when creating in launch4j )
  • etc


And I decided that it is easier to force users to install java than to suffer with packaging and other things.


A logical question appears: is it enough to download and install Java ( java.com/download ) so that the application runs stably and without any errors, regardless of whether it is jar or exe , obtained in any of the ways? Or do you need something else to set up, set variable environments and so on?

If necessary, it is necessary to automate it, not all users are able to do this :)

If I think extremely wrong, or I make mistakes, because of which applications become unstable and do not work, please indicate this and, if possible, show how to do it correctly (although I don’t know how I could make a mistake when creating an exe via launch4j by pressing just two buttons).

Also, if there are easier ways to distribute a java application, I will be glad to know.


UPDATE: At first, I just threw the jar from the bundle to the person who has the latest version of java on the computer, it also did not start, then he collected the artifact - jar in IDEA, the resulting file was also dropped - the effect is the same as with the exe file: javaw. exe flashes in the processes for a second, and that's it, the program does not start. This happens wherever the file is located. What is the problem? What am I doing wrong?

  • In terms of launch4j, I can advise all libraries to charge in the jar itself. And so my client application stably handles. Print the logs to a file, the application itself collapses. (launch4j does not print to console) - Riĥard Brugekĥaim
  • 2
    I wrote a few years ago at my first job an application in Java, which was run via .exe . What I did .exe myself - I don’t remember, but its essence was reduced to the jre/bin/java -jar app.jar . That is, in the folder with the .exe there was also .jar with the program itself and the jre folder with the JRE. I would not say that this is the best option (especially for users who already have Java installed), but at least it worked, and I did not see any complaints from users about this. - Regent
  • @Regent updated the question: even the usual jar. collected from me, does not run on another computer with java installed. I do not know what could be the reason, everything works fine for me. - Peter Samokhin
  • one
    @PeterSamokhin it is possible that the program crashes when it starts up. Try running this .jar on the "other computer" from the console (again using java -jar name.jar ). - Regent

1 answer 1

  1. To run Java-written applications on other computers where Java is installed, environment variables are not needed . ( verified )
  2. Downloading and installing Java from java.com/download is enough for the application to work.
  3. For myself, I identified two possible ways to conveniently distribute the application: if you do not force the user to install Java, you can download the jre folder once (the path to which is indicated, for example, when creating an exe from the jar using launch4j; or you can provide the user with a jre folder and run the jar file using jre/bin/java -jar app.jar (thanks for the tip to Comrade Comrade ), and, later, to update the program from the user, you can simply provide him with a jar or exe file so that he places it with a replacement in former application directory. If the user has Java installed, there is no need for additional provision of anything, an executable file is sufficient.
  4. Specifically, according to my problem: javaw.exe started only for a second, because the program worked with an error (in the code I indicated the absolute path to the program icon, and therefore there was the most trivial error Can't read input file , but I have problems on my computer naturally, it was not; Thanks to Comrade Regent, I suggested an idea of ​​a possible error ).