I have developed a standalone application using Java and Selenium. When I create an executable jar and run it on my machine, it is working fine, but that executable jar is not working on another machine. On double click, nothing is happening. I want to run my application without installing installing JDK/JRE on that machine. I am using Eclipse and working on Windows 10 machine. Any solution?
-
1There are applications that can convert a jar package into an Windows exe. For example look for Launch4J. There are others as well. – karakfa Jul 24 '20 at 00:59
-
Open the terminal (cmd or shell, whatever) and run .jar file from the terminal `java -jar myfile.jar` and you'll see stacktrace of why doesn't it work – Fenio Jul 24 '20 at 09:18
-
Which version of Java are you using? If it’s Java 11 or later, you can [create a linked application](https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre) which will include a stripped-down copy of your JRE. – VGR Jul 24 '20 at 12:52
-
1Does this answer your question? [Running a java program as an exe in Windows without JRE installed](https://stackoverflow.com/questions/1332548/running-a-java-program-as-an-exe-in-windows-without-jre-installed) – Jason Aller Jul 25 '20 at 04:54
-
Maybe the external machine is running a different version of Java. Try to bundle the jre and the jar file into a executable – billschmidt626 Jul 24 '20 at 01:53
3 Answers
It runs on your machine because you already do have JDK/JRE.
It is not possible to run them without JDK/JRE installed on the target machine. This is the reason for the OS independency. ie. you can run the SAME code/app on Windows MacOS Linux (given that they have JDK/JRE installed).

- 313
- 1
- 3
- 13
-
I saw the below but not sure if that will work or not. any comment on the below approach? == 1. Create a folder(lets say PROGRAM) which include folders bin and lib, of your installed JRE. In my computer I can find them at this path: C:\Program Files\Java\jre1.8.0_25 2. Then with Launch4J create a JAR or Exe file of your program inside that containing folder(PROGRAM). Also when you create this file you need to manually select root to these bin and lib folders. 3. Then you don't need to have JRE installed, however you only need to have folder with program and also bin and lib files in it. – Pawan Choudhary Jul 24 '20 at 02:33
u need use gradle or maven to deploy standAlone app with java (java 11+) ,, i am actually using gradle.
on build.gradle : add org.beryx.runtime on plugin ->
plugins {
id 'java'
id 'application'
id 'org.beryx.runtime' version '1.9.1'
}
runtime {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
jpackage {
imageOptions = ["--icon", file("/icon/icon.ico")]
imageName = "ur exe name"
skipInstaller = true
}
}
this is will produce exe file with jdk/jre runtime inside,, for my project iam using jdk14.0.1 , gradle-6.4.
go to Beryx Badass github for more deep info about this

- 19
- 3
There are online compilers that can run basic code. https://www.tutorialspoint.com/compile_java_online.php
It is best to use JDK/JRE locally when coding more complex systems that import libraries and save and load files, etc.

- 11
- 2