Open the thick "Java JDK8 study Notes", began to have a feeling of disorientation. Total feeling learning this language how so complex, why not like learning C language as directly learning the corresponding grammar rules, take some of the program examples to practice practiced hand will be, why the book in front of so many "irrelevant" content.
In fact, when I sank into the heart to endure slowly read the "Chapter 1 Java Platform Introduction", understand the "sharpening does not mistakenly cut timber workers" principle. The first chapter elaborates the origin and development of Java, and the introduction of some professional nouns. So I got a big impression from the beginning and I had a more systematic impression of Java. One of the most impressive is that Java has three platforms, namely Java SE, Java ee, java me,java EE relative Java se Advanced, Java ME is mainly in small digital devices development, so for beginners like us, of course, the contact is Java SE, and now Java has grown to "Java SE 8".
After understanding the platform, the first chapter is more important is the understanding of the three jvm/jre/jdk. I just say in terms of learning understanding the relationship between the three, the JVM is the meaning of the Java Virtual machine, the. class file to run, or the system can not directly run. This book also emphasizes its importance, emphasizing that "the JVM is the only operating system known to the Java program, and its executable file is a. Class document" important concept. The JRE refers to the Java operating environment, that is, Java program to execute, always have a suitable environment for it, like C language, the same needs the environment, it is impossible to simply execute them. The JDK contains some Java language development tools that must be installed in order to develop Java programs.
In summary, the JVM is necessary to read Java programs, and the JRE provides an environment for running Java programs, and the JDK provides development tools for Java programs. As a result, the three are included, and the JDK includes the JRE,JRE and the JVM. Java's cross-platform is embodied in Java has a different version of the JDK, can be used for Windows, Linux, Max and other operating systems, Java programs are unchanged, only need to change the corresponding JDK, you can develop running Java programs on any platform.
The above is I learned some of the first chapter of the harvest, a general understanding of the meaning of these nouns, should be a follow-up study will have some help.
Follow the contents of the book, on the corresponding website download the latest "jdk1.8.0_72", after installation, is to set environment variables. The environment variable is set up for a more convenient Java program compilation, set the environment variable "PATH" can be directly at the command prompt call "Javac" command, this command is right. Java file compilation, build the. class file in the same directory, and finally run the. class file through the "Java" command, which is a bit like compiling and running in VC6, except that these are all done at the command prompt. Start a little to understand the book, do not know how to type this command, do not know the interface of those "directory address" is how to change, for this particular check some of the commonly used commands "cd\", "CD.", "dir" and so on, indeed to understand the contents of the book has certain help. is the set PATH environment variable.
Then I started my first program "Hello World" with the textbook. Hit the Code of "Hello World" as in the code of the book.
Roughly understand the meaning of the program, class represents a class, HelloWorld is the name of the class, because class is preceded by public, so HelloWorld is still an open class, A. Java document can have multiple classes, but only one public class, and when there is a public class, ensure that the. Java document name matches the public class name. "public static void Main (string[] args)" is a bit like the sentence in C, and the main and C language also feel similar, is the entry point of the program. The following sentence can be broadly understood, is to print out "Hello World" this string of characters. The curly braces represent chunks, and the C language should be the same.
After you have finished typing the above code, save the Notepad as a. java format to the appropriate directory. Then, bring up the command prompt, compile the. java file with the "Javac" command, build the. class file, and then use the command "Java" to execute the corresponding. class execution file and print the result output on the screen as well.
Above is I use the method of the book to write the first Java applet, although feel this method is a bit troublesome, but set up environment variable also did not feel too cumbersome, but let me understand and C language is different, C language is in the corresponding compiler software inside first knock code, then point to compile the point to run, automatically results , and this is through the command prompt, each step of the execution requires you in the Black dialog box to be issued "instructions" to complete, experienced a different programming process.
Hello Java!