Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

What's the difference between a Java Process (what your OS sees) and a JVM? Are they one in the same or are they actually different?

How are the JRE and JDK different (in purpose and file content), and which one contains the libraries for Java SE?

What's the difference between the Java "Runtime" and a JVM?

These are questions I've been asking myself (and colleagues) for years and everybody seems to have very different answers.

share|improve this question
2  
I see this is downvoted - please explain why! This is on topic for the site, and I cannot find a question that is an exact duplicate to this one. –  herpylderp Jul 7 '12 at 12:12
3  
It doesn't show any research effort: Most of these questions (you are asking too many in one) can be answered by using e.g. Google or Wikipedia. –  Martin Schröder Jul 7 '12 at 16:15
    
"These are questions I've been asking colleagues for years and everybody seems to have very different answers." - Yea, people are annoying like that. :-) Different people understand things differently and have different ways of explaining them. Some of them may even be ... wrong. Get over it. –  Stephen C Jul 8 '12 at 6:41
add comment

closed as not a real question by Jarrod Roberson, Thorbjørn Ravn Andersen, ChrisF Jul 7 '12 at 22:13

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

These terms aren't ambiguous; instead, they're probably just being misused where you're reading them.

First, a process is just that -- a process, in the sense of the operating system term. The JVM is the virtual machine that runs Java code; there isn't a sense of "multiple JVMs" in this context.

The JRE is the software package that allows you to actually run Java apps, as an end user; the JDK is the development kit that includes the development libraries and other necessities for writing your own Java programs.

The "Java runtime" probably means a JRE, or, specifically, the java binary that is invoked to run a Java program (i.e. java -jar myprogram.jar). This invokes an instance of the JVM, essentially, to run the bytecode contained in that program, which was compiled with the java compiler from the JDK (javac).

share|improve this answer
    
Thanks @syrion (+1) - please see my comment to alex's answer - I have the same question for you! –  herpylderp Jul 7 '12 at 12:23
    
Answered it there, since your question is there. :) –  syrion Jul 7 '12 at 12:32
add comment

The JVM is the virtual machine which can interpret Java bytecode (and typically, compile it to the host's native code), load Java classes and provide the minimal native services to run Java's native library.

Typically, when you run a JVM, it spawns an OS process.

The Java Development Kit (JDK) is the Java Runtime Environment (which contains the necessary stuff to run a JVM and the Java standard libraries) + the Java compiler and tools. You need a JRE to run Java programs; a JDK is a a bundle which allows you to compile and run Java programs (note that there are alternative Java compilers).

share|improve this answer
    
Thanks @alex (+1) - so does the Process Java object correspond to the spawned OS process the JVM is running on? Similarly, is the Runtime Java object an in-memory "version" of the system JRE (and all its properties, attributes, etc.)? Thanks again! –  herpylderp Jul 7 '12 at 12:22
    
In essence, yes. However, they are really just interfaces to those concepts; Runtime.exec() spawns a Process, for example. –  syrion Jul 7 '12 at 12:31
add comment

To make the java-bytecode, and the Java software in general, portable, James Gosling and his team invented a JVM which is a virtual machine capable of running your bytecode and translate that series of statements in actual machine code.

Each Operative System and platform has its own JVM but you can run the same bytecode in each one of them.

You can see the JVM like a sandbox, your OS can't see the process related to your java application directly because this happens internally, in the JVM itself and the process related to the JVM is taking care of managing your memory and your resources.

the JRE are basically the collection of libraries that comes with a standard versione of the Java platform, the word "Java" is used to indicate both the language and a generic Java platform, to be a little bit more specific about the platform you can use labels that are part of the Java world like J2SE, J2EE and J2ME.

  • J2SE is a java profile for the desktop
  • J2EE is a java profile made for the enterprise
  • J2ME is a java profile made for mobile and low end devices

but this definitions are not really needed because with the evolution of the hardware something can change, for example on the Android platform you find a J2SE implementation of the JAVA platform rather than a J2ME wich was far more popular on mobile in the Symbian era.

The JDK is maded by the JRE + all the things that you need to develop with java, so the JDK comes with a javac compiler, a doc utility like javadoc and just everything you need to get started creating your own java applications.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.