September 3rd, 2008 The first cup none Comments

 

RUN, RUN RUN

 

Well, a java program just does not run like any other program written in any other language. There is no direct windows .exe file which can be generated( as of now in my lessons). Now back to the question -how do we run the file?

Java, is a platform independent language. But any java program we write has to be run in an environment, be it any platform, and the concept of a paltform independence means that if i write a program in my laptop(windows), it should work fine in my brother’s mac, or for that sake in my friend’s laptop(linux) as well.

This is achieved not by any platform independence funda, but by a virtual machine which allows the program to be a “write once run anywhere code”-as java lovers call it. So, it is but evident that every OS, has it’s own JVM-the java virtual machine. It behaves like an emulator, thereby making the program believe that it is running in a java environment.

For more info on JVM, see here.

So, if you have a J2SDK installed(suggested use is 1.6) and a JVM installed, try the following ::

 

javac "filename.java"

This will compile your program and generate the necessary bytecodes which is converted to executable code by the JVM, with the help of a JIT(Just in time) compiler which is a component of the JVM. If there are any errors, you will see it, correct them, and if not move to ::

java "filename"

This should do. Try to keep you program in the bin folder of the java installation, or else use ::

javac -c "path to the program class file" "filename.java"

Once you know it is done like this, use an stop using the boring command line and move to an IDE with auto complete-as i suggested here.

Using an IDE is an opposed idea, byt you getto know about a lot of overloaded functions, which they do not teach. So, use an IDE for faster development and better knowledge and proficiency with a language. Ok, now that the program runs, well’ move on to new things in further posts..

No Responses to “This program, how does it run!”

No comments yet

Leave a Reply

 

RSS