I installed the last JDK from this website (Java SE 14.0.2). This installed both jdk14.0.2 and jre1.8.0_231 in the java folder of my Program Files folder.
I want to make a .exe file out of my jar files using Launch4j however, I can't run Launch4j because everytime I try, it says it requires a java runtime environment. I'm confused because I should already have one installed (jre1.8.0_231), so why isn't it recognizing that?
Related
I am building an installer for a JavaFX 1.8 Windows application.
This application contains a JNI.
When I run the Ant script with the jdk 1.8.0_172, files named api-ms-win-core-*.dll and ucrtbase.dll are copied to the runtime\bin install directory. Those files are not present when I run the exact same script with jdk 1.8.0_144.
I have tested my program without those files and it works fine. What could be a path to investigate to understand how to get rid of those files?
Also, msvcp120.dll is updated to msvcp140.dll and vcruntime140.dll file appears (and is needed).
Thanks!
This question already has answers here:
Running java without installing jre?
(8 answers)
Closed 4 years ago.
I made an executable jar file but I want to distribute it to users who may not have Java installed on there computers (Mac or PC). Is there anything I could do anything on my part as the programmer to make sure people without Java can run?
Other than 1) asking them to install Java, or 2) writing your own JVM, the answer is generally no. You have to have a JVM/JRE for your jar file, unless you have a development environment that can create a native executable from your code. But, then it won't be a standard jar file - it will be a native binary (if this development environment just bundles a JVM of some sort into package containing your jar file, with a small executable stub - this would still be putting JVM on their machine - it would just be a bit hidden from a user). So unless you can generate a native binary (not a jar file) from your source, no.
Same with writing something in .NET and attempting to execute it in an environment that does not understand what .NET is, writing something that requires a Python interpreter and trying to run it in and environment without Python, etc.
Running java without installing jre?
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
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.
Then user dont need to have JRE installed, hovewer he needs to have folder with program and also bin and lib files in it.
If my english is not enough and these type of solution is what you looking for then heres another source...
How to bundle a JRE with Launch4j?
No need for Launch4j or any other software. Convert your project to .jar file in eclipse then after that put your installed JRE folder in the same folder where your .jar file exists.
Uninstall JAVA from your system then go to JRE folder in that bin folder then open command prompt.
Type:
java -jar ..\..\fileName.jar
i.e java -jar ..slash..slashfileName.jar
Make sure that the JRE installed file and your .jar file is in the same folder.
I want to create a executable jar file of a small game that i wrote in java and make it playable in any machine with simple double click like exe file. My question is do you need to install java runtime first in order for executable jar file to work or can it work on a machine without any java installed as well?
No it can't. However, clients do not require the JDK, the JRE would do.
You can make your jar declare its own main class and have users double click it normally like an exe file or create a bat file in Windows.
It requires a JRE instance to be installed on the host machine. This is because JAR files are actually executed via a command line like (in Windows):
java -jar ...
This means that somewhere on your system the java.exe executable should be reachable, either by including its folder in the PATH (Windows) or replacing java with its full path.
Also, most likely you will need to have all the runtime Java libraries to be hosted on the system, as the JAR file containing the application you want to run is not supposed to contain all the Java API libraries. They are also part of the JRE package.
My explanation is tied to Windows for the sake of examples, but it can be extended to any OS.
Do you need to install java runtime first in order for executable jar file to work?
Yes, of course. To run Java .jar files first you need to have installed at least the JRE (run time environment). The JDK (development kit) is a superset of the JRE and will also work for running .jar files.
Can it work on a machine without any java installed as well?
No, as mentioned above, at the bare minimum the JRE must be installed.
You have to have a Java runtime environment (JRE) available on the machine unless you use a tool that performs ahead-of-time compilation (AOT, which is contrast to the usual Just-In-Time). Such tools are available (such as Excelsior JET), but they have a number of downsides, including cost and the fact that a precompiled Java application is a regular executable and will only run on one operating system. I've seen some installers that will detect whether a JRE is installed and launch the Java installer for the user if not.
Yes ! of course, JRE is required and it is not compulsory for JDK to be installed. Since, the main class is defined in JRE for .jar files, it is necessary to have JRE on your machine. I tried with Windows OS.
Actually you can bundle JRE within your exe file with several java .exe wrappers.
Here are few of them JSmooth, Launch4j, Jar2Exe.
I want to run .jar file on a machine which does not have jdk or jre. Is it possible, if yes then how?
I tried to run my .jar file on a machine which does not have jdk or jre, it fails.
I can assure you that you will need a JVM at some point. A JVM is included in either the JDK or JRE. (JDK is needed for development).
Whether that JVM is pre-installed or bundled with your executable is up to you.
You may want to check launch4j project as an example. There are many other java "wrappers" like this.
The JRE software package is needed to use java application while JDK software package is needed to create java application. So
JDK ---> programmer and software developer
JRE ---> common everyday user.
Some jdk include jre.
Thank you.
Jar is just archive with .class files. You can't run .jar file on machine which doesn't have jre, because jre executes .jar .
I made a desktop application with Java netbeans, it's a Jframe with some components. I built it and the .jar file created in the dist folder in the project folder. I have already the jre (Java Runtime Environment) installed on my pc. When I try to open the .jar with the jre I got nothing, Nothing appears. What can I do ?
https://netbeans.org/kb/articles/javase-deploy.html#Exercise_1
The link above will take you to a tutorial. Jar files are not executable by default. You need to specify a starting class to make a jar file executable.
If this doesn't work, then make sure you have called setVisible(true) on your JFrame.
Edited to add: (author added info)
When I try to run through CMD there's Unsupported major.minor version 52.0
This means your JRE version does not match your compiler version. You can confirm with the -version option, then fix your path to use Java from the same place your compiler lives.