Date :july-27-2016
6.
Execute
java application :
To excite java application, we have to use the following commend prompt
from the location, where main class .class file is existed.
>>javac Main_Class_Name
Ex:-
D:\java10>java FirstApp
If want above the commands on command prompt then operating system will
perform the following action
1.
Operating system will tack “java” commend from commend
prompt.
2.
Operating system will identify “java” commend at
“C:\java\jdk1.7.0\bin” through the “path” environment variable.
3.
Operating system will activate JVM by executing
“java” commends.
When JVM software is activate then JVm will perform the
following actions.
a.
JVM will take main class name from command
prompt which we provided along with “java” commend.
b.
JVM will search for main class .class file at
current location, at java predefined library and at the location reference by
the “class path” environment variable.
c.
If main
class .class file is not identified at all the above locations. The JVM will
provide the following messages.
JAVA6 :
java.lang.NoClassDefFoundError: FirstApp
Java7: Error: Cloud not find or
load main class FirstApp
Note:-
If main class .class file is
available at some other location then to make available main class .class file
to JVM we have to set “classpath” environment.
D:\java10>set classpath=E:\abc;
d.
If main class .class file is available at either
of the above specified locations then JVM will load its byte code to the
memory.
e.
After loading main class byte code to the memory
JVM will search for main method. If main() method is not identified then JVM will provide the following messages.
JAVA6:
java.lang.NoSearchMethodError: main
JAVA7: Error: main method not found in
class FirstApp, please define the main method as
>>public static void main(String[]
args)
f.
If main() method is identified in the loaded
main class then JVM will create a thread called as “main thread” and JVM will
execute main() method with main thread.
g.
Main thread execute the compile body of
main()method, when main thread reach to ending point of main() method,
automatically, main thread will come to dead state.
h.
When main thread is coming to dead state, JVM
will stop all of its internal process which are assigned for the present
program then JVM will go to shutdown mode.
No comments:
Post a Comment