Implications of Old version of Java.exe (7.1) using new version of runtime(8.x)
java.exe
is a simple launcher. It does not contain JVM or Class Library code. Its primary function is just to locate a JRE and to load jvm.dll
with the arguments passed in the command line.
You can start a JVM using the Invocation API even without java.exe
.
java.c
log tells there are not really much changes in the launcher between JDK 7 and JDK 8. E.g. there is a launcher support for JavaFX applications and a few fixes for better argument validation. That's it. So if your application starts fine with JDK 7 launcher, there is apparently nothing to worry about.
What exactly is the java executable, what does it do and where can I find the sources for it?
The primary source file for the launcher in the current development JDK can be found here: https://github.com/openjdk/jdk/blob/master/src/java.base/share/native/libjli/java.c
As you see, it's quite short and delegates most of the work to other pieces of code, but should be useful as a starting point.
If you want to see the source for other JDK versions (this is basically the main development repo for future Java versions), you need to look into the appropriate repository.
Is the 'java' executable the JVM?
The JVM is defined as: The JVM is the ‘virtual machine’ that runs the Java bytecodes.
Isn't that what the 'java' executable provided in the JDK does?
In effect, yes. You can think of the java
executable as a "front end" or "launcher" for the JVM: you give it the name of an entry class, and it kicks off a JVM instance and executes the that class's main
method. You could host a JVM instance in your own application using a hosting API, but the java
executable is the de facto way to spool up a JVM instance for the purpose of running a specific Java program.
There are also applications which 'bootstrap' the JVM: they are Java applications that have their own platform-dependent "launcher", which lets them behave more like native applications, in that you can run them directly instead going through the java
executable. Many of the Java compiler tools are packaged this way (e.g., javac
, javap
) as are many Java IDEs (e.g., IntelliJ, Eclipse, etc.).
when an instance of the JVM is instantiated?
java (java.exe in Windows) is an application, it is a wrapper over jvm library (jvm.dll in Windows). We can say java.exe is a JVM launcher.
Some nuances in jre explanation
Q: It is possible to compile only using jdk ? I mean get .class files ?
A: Yes, e.g. javac Main.java will produce Main.class
Q: JRE needed to run java ? how it run if it can't compile class?
A: For example I give you a .class file, and you can run it on your jre. The .clas is compiled by me, you just run it.
Q: why JRE provide jvm if it can't compile ?
A: JRE is for clients. They don't need to compile .java files, the just need to run .class files. Developers need to compile .java files, which produces .class files.
Q: Did I missed something in jdk explanation ?
A: No.
Related Topics
Accessing Post Variables Using Java Servlets
Gson and Deserializing an Array of Objects with Arrays in It
List All Files in the Folder and Also Sub Folders
Possible to Use Two Java Classes with Same Name and Same Package
How Do Determine If an Object Is Locked (Synchronized) So Not to Block in Java
Java - How to Create New Entry (Key, Value)
Uninitialized Object VS Object Initialized to Null
How to Attach Multiple Files to an Email Using Javamail
Eclipse Reading Stdin (System.In) from a File
Maximum Size of Hashset, Vector, Linkedlist
Jframe.Dispose() VS System.Exit()
Difference Between Wait and Blocked Thread States
Class Object of Generic Class (Java)
How to Replace Groups in Java Regex