java study notes--the first day

   As a programmer, I don't have the habit of blogging, and today I am deeply despised by the project team boss. Start today and write a blog every day.

   In the morning, I went to install the jdk environment for the new employees. The environment variables depended on Baidu. I couldn't bear it. The first blog started from 0 to the well-known helloworld. First, download the JDK, run the .exe, and go all the way to next. If you don't want to install it on the c drive, you can change the installation directory on the custom installation interface. Download and install will not go into details, programmers who will not download and install. . . . I think it's quite profitable to sell fruit.

   After downloading and installing (my installation directory is C:\Program Files\Java), there will be two folders in the C:\Program Files\Java directory, one is jdk1.6.0_33, the other is jre6, the version number It doesn't matter, mainly depends on jdk* and jre*, where jdk is the java development environment, if you need to develop java code, you need this folder, jre is the java runtime environment (let's call it that...), if you don't develop java code, just run someone else's or your own java program, that is, run the .class file, then this folder is fine. Entering the bin directory under the jre* folder, you can find that there is no javac.exe file, which means that he cannot compile the .java code.

   After the installation is complete, open cmd, run the java and javac commands, and find that it cannot be recognized because our environment variables have not been configured. If you open the bin folder in your java installation directory in cmd at this time, such as C:\Program Files\Java\jdk1.6.0_33\bin on my computer, then you can run java and javac command.

   There are three main configuration of java environment variables, JAVA_HOME, CLASSPATH, PATH. JAVA_HOME is not necessary, if it is not equipped with JAVA_HOME, it is also possible, but in general, we configure JAVA_HOME, which is comfortable and convenient to configure subsequent parameters. My local configuration JAVA_HOME is C:\Program Files\Java\jdk1.6.0_33. The second is to configure the path variable: PATH=%JAVA_HOME%\bin;%PATH%; What is the use of the path variable? Its function is to let us run java commands, such as javac.exe or java.exe, without opening the java bin directory in cmd, and when typing java commands directly in any directory, the operating system will automatically start from Find the java command in the directory where path is located. Finally, configure the classpath variable: CLASSPATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar; classpath refers to the search path of the class. His role is to tell the jvm (java virtual machine) to find it from these directories when we need a class.

   As for tools.java, why should it be configured into the classpath, this is because tools.jar is a tool class library. We can see that each exe file in the bin directory is very small, generally more than 20K, this is because they are actually a layer of code packaging, which means that they also need to call other codes. So where is the call? In fact, it is to call the class in tools. Equivalent to the class in tools, it is the concrete implementation of the tool class. Open tools.jar with compression software, and you will find that many of his files correspond to the files under bin.

       

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326269472&siteId=291194637