No, the Java Runtime Environment (JRE) has both compiling and interpreting modes. Both are available either if the program is run inside of an IDE, or started from the command line.

compilation means changing the source code to .exe file in C/C++ and in java to bytecode(.class) so that jvm can run it is it right?

With Java the source first gets compiled into bytecode in class files. Then at runtime the bytecode is interpreted, and may optionally be compiled to native machine code. When I say "optionally", what that means is that almost always it will get compiled. Using only interpretation makes for much slower programs. [ November 13, 2007: Message edited by: Ulf Dittmer ]

Java uses a combination of compilation and interpretation. When you create and save a Java source code file (the file that contains your Java instructions and is saved using the .java extension) it needs to be translated before a computer can understand the instructions. So we compile the .java file. However, unlike other compiled languages, the Java compiler does not produce machine code designed specifically for a particular type of computer. Instead, it produces a new file containing bytecode, and this file has the .class extension. Bytecode is like an idealised form of machine language, and the really special thing about bytecode is that it is not machine dependent. Another words, the bytecode produced by the Java compiler is not designed so that only one type of computer can read it, any computer (that has the Java interpreter installed) can read and understand bytecode. The Java interpreter is sometimes referred to as the "Java Virtual Machine" ( Java VM for short) and some books even refer to it as the "Java run-time system". The interpreter on your computer takes the Java bytecode in the .class file, turns it into machine code which your particular computer can understand, and then executes (or "runs") the code.

You might wonder why the Java creators designed things this way - why use a two stage approach instead of just compiling or just interpreting the code like most other languages do? Well, the advantage is that once a Java file has been compiled, any computer with a Java VM can interpret and run that file. So the code is a lot more portable. Think about the huge number of network and Internet applications we run today - lots of different types of computers trying to communicate with each other. This approach overcomes these machine-dependency problems.