Does a jar file run without a presence of jdk | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Does a jar file run without a presence of jdk

I have created a jar file successfully and want it to run on other computer. If i copy it through a pen drive and paste it over the other computer than i want to know will it run or not. If it does not run please give me a suitable answer for how can i do so

29th Mar 2019, 9:23 AM
Rajb957
Rajb957 - avatar
7 Answers
+ 10
If Java is preinstalled, yes. If not, no ;)
30th Mar 2019, 7:00 AM
Tashi N
Tashi N - avatar
+ 12
You need Java, to be more precise: jre, installed to run a jar file.
29th Mar 2019, 12:56 PM
Tashi N
Tashi N - avatar
+ 10
It is possible to pack your program together with the needed runtime environment so that your program files contain the jre you need to run it. See https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html Usually you want to deliver a setup.exe or msi (Windows OS). Then you need to put all needed sources, jre and others, to the setup. If you want to go that way, I recommend to look into build tools like Maven or Ant, because it will make the deployment much easier once you are familiar with them.
30th Mar 2019, 7:16 AM
Tashi N
Tashi N - avatar
+ 2
Then how are computer softwares of java made because when a computer software is installed at that time no jdk or jre needs to be installed additionaly Tashi N
30th Mar 2019, 7:02 AM
Rajb957
Rajb957 - avatar
+ 1
in case if i buy a new computer as it is with default applications and no additional downloads can it be possible Tashi N
29th Mar 2019, 3:03 PM
Rajb957
Rajb957 - avatar
0
You'll need JDK in order to develop in Java. If all you want is to run a Java application you will only need JRE. For the case of running a jar file use: java -jar your_jar_file.jar
30th Mar 2019, 6:57 PM
Rodrigo J. Silva
Rodrigo J. Silva - avatar
0
yes
30th Mar 2019, 8:25 PM
Jaedon Person
Jaedon Person - avatar