I have been reading many answers about the different between the compile time and the runtime in Java. But I am still not clear. Some answers said: the compile time is the period when you, the developer, are compiling your program or code. My question is when do I compile my program or code? For example: I open my IDE, eclipse or netbeans, write code in different classes and click on Run button and my application opens. Can someone explain me when did I compile my program/code in this sample process? or when was I in the compile time stage in this sample process?
When you write any java class,extension of file must be .java. Let take simple java class to print Hello World :
public class Simple {
public static void main(String[] args) {
System.out.println("Hello World !!");
}
}
So save this file as Simple.java.
Now open the cmd,lets say file saved in d:\test directory
d:\test>javac Simple.java // When you run this the .java is converted into byte code and it is saved in .class
file.
d:\test>java Simple // JVM will execute the byte code file i.e. Simple.class
Note
: All this process is done by IDE internally
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With