Monday, November 7, 2011

Running JRE

JRE looks no different from any other program on your computer.
For example, on my Windows computer, I have a folder:
C:\Program Files\Java\

Here I have a folder:
C:\Program Files\Java\jre6

In this I have:
C:\Program Files\Java\jre6\bin
C:\Program Files\Java\jre6\lib

Inside my bin, I have a java.exe

When I run the java.exe, I am running JRE -- thats it!

I could open a command prompt and type 'java.exe', or I could double click on it in Windows Explorer, or I can run it from Start-->Run...

Suppose I had a simple Java program, say HelloWorld - I could run it from the command line like this:
> java HelloWorld

This will call the java.exe in the C:\Program Files\Java\jre6\bin, then pass it HelloWorld as an argument. java.exe will then read and execute HelloWorld. If HelloWorld had a print("Hello World!") statement, you will see this printed on the console.

This is no different from running any other program.

Note that JRE itself is written in C/C++, so you are really running just a C/C++ program called java.exe, with an argument - you have done this before, nothing to do with Java!

1 comment:

Anonymous said...

Hi Mahesh,

You could say:

When I run the java.exe, I am running the JRE -- thats it!

instead of

When I run the java.exe, I am running Java -- thats it!