www said:
I am sorry. I am still not clear: what is the difference between Java
compile(javac) and Java JVM?
When we say Java 1.5(or 5.0), does that mean Java JVM 1.5 or Java
compiler 1.5 or both? Thank you.
Lew has already given you a lot of detail. Here's a slightly different view...
Every year or so, Sun release a new version of Java, both the language itself,
and all the runtime machinery needed to execute programs written in the
language. The runtime stuff is the JVM (you can think of that as the java.exe
program), plus the runtime class libraries that your programs depend on.
When they release each version, then tend to do something stupidly confusing to
the "official" names, which is why sensible programmers ignore what Sun say,
and stick to using the 1.4, 1.5, 1.6 and so on names. Currently 1.4 is
reaching the end of its life, 1.5 is current, 1.6 has recently come out, and
1.7 is not yet available.
When Sun make a new version, they release two different "products" for ordinary
use. One is the "JRE" (which used to stand for Java Runtime Environment, but
probably Sun have given it some different name now -- but it's still called
"JRE"), and the other is the "JDK" (same point applies). The JRE is what
end-users need on their machines in order to run Java programs, including
ordinary programs (run with java.exe), clickable JAR files, applets, and Web
Start applications. The JDK is what you, as a programmer, need in order to
/write/ applications, it includes things like javac.exe (the Java compiler).
So users need a JRE, programmers need a JDK. So far, Sun have had the sense to
keep the version numbers of the two products together. So if you have written
your programs using a 1.5 JDK, then your users will need to install a 1.5 (or
later) JRE. If you upgrade to developing using a 1.6 JDK, then (unless you
take special steps) your users will have to upgrade to a 1.6 JRE.
One last thing. When you download and install a JDK, that includes a JRE as
well -- in fact it normally includes /two/ JREs (yes, that's confusing too --
blame Sun). One of the JREs is exactly like the one that any ordinary user
would get if they installed a JRE on their machine, and is installed in the
same place; the other is put in the JDK installation directory so that the JDK
can use it. (I suppose the idea of having two is that we can keep the "user"
JRE clean for testing, while we can change options, and so on, in the
development copy, but I'm not really sure).
-- chris