From the existing threads (What tomcat requires JDK or JRE? and Why does Tomcat require JDK installed?) I learned that Tomcat 5.5 onwards does not need an installed JDK to compile jsp files, because it uses its own bundled Eclipse Java Compiler. However, when tomcat runs the java byte code, it does require JRE. But during installation of Tomcat, we only need to specify the location of JVM. To compile and run Java code, we only need to add bin folder under the JDK folder into the path environment. But JDK 9 does not include a JRE folder any more. Instead there is an independent JRE folder outside JDK folder. How does Tomcat still catches JRE when running compiled jsp code? Which configuration file in Tomcat captures this? Thanks!
But during installation of Tomcat, we only need to specify the location of JVM
Specifying the location of the JVM implicitly specifies the location of the JRE, since the JVM is locate inside the JRE directory structure.
To compile and run Java code, we only need to add bin folder under the JDK folder into the path environment.
Adding the JDK bin folder to the PATH, means that you can run the java and javac commands. The location of the command file implicitly specifies the location of the JDK, and hence the JVM, to use. There are no configuration files.
In Windows 64-bit Java 5 to Java 8, the JVM is located in %JAVA_HOME%\jre\bin\server\jvm.dll.
In Windows 64-bit Java 9, the JVM is located in %JAVA_HOME%\bin\server\jvm.dll.
But JDK 9 does not include a JRE folder any more. Instead there is an independent JRE folder outside JDK folder.
The JDK installation programs for all Java versions will create both a JDK folder and a JRE folder, unless you tell it not to create the separate JRE folder. Java 9 is no different that older Java versions in that regard.
How does Tomcat still catches JRE when running compiled jsp code?
Tomcat is itself written in Java, so Tomcat doesn't locate Java. It is Java that runs Tomcat.
Related
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?
I want to set my java_home variable,
but have a custom enough OS not to be able
to find my jdk dir as prompted everywhere
(it's a chromium os, and has installed jdk8 by chromebrew...).
What i have is a usr/local/jre folder,
and few java* binaries in usr/local/bin.
Can the jre I have be the same that
everyone refers to as /usr/java or /usr/java/jdk?
The jre folder includes a bin, lib and plugin folder and some tl;dr files.
Thanks a lot!
There is no "standard" definition for the JAVA_HOME, that is you can point it to the folder where either the JRE or the JDK is installed.
The only requirement (which is in fact more of a generally accepted convention) is that $JAVA_HOME/bin/java should start the Java runtime.
This happens if you point JAVA_HOME to either the JDK or JRE folder, in both cases there is a folder /bin and inside the "java" executable.
In your case, since you identified the JRE installation folder, you can point JAVA_HOME to it.
I exported my project to an executable jar and noticed that eclipse also packaged the external jars I used. When trying to run it on a different machine (which did not have JRE installed), it failed giving the reason that JRE is missing. What is the difference then between the JRE referenced in my project and the JRE I installed from Oracle after I received the error message?
The JRE is more than just the libraries you're referring to - it's the whole JVM. Also, the JRE wouldn't be included in "external jars" anyway. It's generally assumed that the target of a Java application will already have Java installed - you really wouldn't want to bundle the whole JRE with it, normally.
There are packaging applications which will bundle a JRE with your application - but bear in mind that you'll then have a separate installer for each target platform (OSX, Linux, Windows - and varieties of CPU architecture).
I suggest you look at the jar file that has been created for you - you can rename it to a .zip file and explore it with normal zip file utilities - and then compare its size with the size of a JRE. Unless you're using a really large set of external libraries, I strongly suspect you'll find your application is much smaller than a full JRE.
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 .