You are on page 1of 1

JDK, JRE, JVM, and Your First Java Program JDK stands for Java Development Kit, which

contains javac.exe which compiles the source code source files (.java files) into a .class file. If a source file has more than one class, each class is compiled into a separate .class file. JRE st ands for Java Runtime Environment and contains the jvm (the interpreter java.ex e) which reads the byte code and translates it into the native language of the h ost machine on the fly. See javajee.com/java-as-a-compiled-and-interpreted-language for more clarity. Let us now write our first java program, compile it into a .class file and then execute it using java.exe. A java program is written in a .java file, which is c alled as our source file. As you have seen everything in java should be enclosed . So we will have to write a Class inside our .java file. It has the following s yntax: public class Hello { } Where public is the access modifier and tells where all we can use our class. Th e class word next to public is a keyword. Java keywords are a reserved set of wo rds that java uses in its syntaxes and are not allowed to be used by us for any other purpose. There are some simple rules for declaring classes in a java file like: There can be only one public class per source code file. If there is a public class in a file, the name of the file must match the name of the public class and it is case sensitive. A file can have more than one non-public class. Files with no public classes can have a name that does not match any of the class es in the file.

You might also like