Thinking of the first course of winter vacation camp


Preface

Since I heard that the winter vacation training team was going to learn a new language "Java", they started to learn Java by themselves for the first time, so before the start of the training on January 25, the software was downloaded and configured. Because it is self-study, watching videos and reading books did not get better guidance. Before I saw the senior’s blog on January 24, I had been debugging in the CMD window. Later, I learned that there was an integrated development environment like IDEA. And after being used by a prostitute, it smells really good !

Since my initial learning was all debugged by the CMD command window, there may be some different opinions on the impact of the environment configuration.

Maybe some friends who have nothing to do with the training camp accidentally click into this blog on the forum. If you have doubts about the environment configuration of Java, you can also refer to the "Environment Configuration" section at the end of the article. Although it is not necessarily correct, you can use it. reference. And it is recommended to read the blog linked below, which has a detailed introduction to Java knowledge.

Attached here is a link to the senior blogger-[Software Innovation Lab 2021 Winter Holiday Camp] Java technology training-Java pre-knowledge learning


Thinking about what I want to do

When filling in the volunteers, the first thing that popped out was "I can't choose physics in high school for nothing", "I want to make money in the future" and "I want to be interested and able to stick to it". Combining my scores, I decided to study. Computer, I hope to develop a mobile game in the future and engage in back-end development.I wrote this paragraph because I think no matter what you learn, goals are very important.

Future plan

Study plan

Since my major is software engineering (sino-foreign cooperation), I will have a certain advantage in going abroad. Therefore, I hope that I can study in graduate school in the future and study in a better foreign school. I choose a foreign country because I think I have the same strength (score). If you go abroad, there are more opportunities and less pressure, which is conducive to in-depth learning.

career planning

My future career plan, first of all, because the conditions in my family are fairly good and can support my business, I still hope that I can start a business. Entrepreneurship may have higher requirements for my own abilities, so I hope that I can study in depth in the field I am interested in and plan to specialize, and at the same time I can extensively dabble in other fields and broaden my horizons.


Areas of interest

When I first joined the club, I did not have a clear understanding of the goal of mobile game development. After recruiting new seniors, I learned that mobile game development can basically be divided into front-end and back-end, and the front-end development will still be involved after in-depth study Back-end development, so my most interesting area is back-end development, and I also hope to learn some basic front-end knowledge.


About the language of interest

About Java

Java is an object-oriented language, good at server-side development, so I hope to learn Java language in depth.

About Kotlin

I have no relevant knowledge of this language before, but because Kotlin is a development language officially supported by Android, it is compatible with Java, and can be executed in an environment without JVM, so I think it is for an aspiring developer For those who travel, it is necessary to learn this language.


Thoughts on "the essence of language is constraint"

The same goal can be achieved by different languages. Because of the different programming paradigms used, the restrictions are also different. Different languages ​​have different restrictions on achieving the goal. Even if the algorithm is the same, the language restrictions will make the "expression" different .


"Environmental Configuration"

First of all, the development of Java is based on the JDK. The JDK includes the Java operating environment JRE and some basic class libraries, and the JDK includes the JVM and core class libraries. The JVM, the Java virtual machine, is the guarantee of Java's cross-platform performance.
After we install the Java JDK, we need to find the address directory where we installed.
In the first study, I did not use an integrated development environment like IDEA, but directly used the CMD command prompt for debugging.
When we just finished the installation, press ⌘ (start key) and R key to start a running window, enter CMD (not case sensitive), and press enter, a small black window will open, which is the command prompt.
Because it is very convenient to use IDEA, generally no one will use the command prompt to operate. Therefore, some introductions on the use of the command prompt on the Internet are scattered, so I will introduce the following here.

instruction Features
cd. (cd space plus a dot) View current directory
cd.. (cd space plus two consecutive dots) Return to the previous directory
D: (not case sensitive) Jump directory to D drive
D:xxxx\xxxx Enter the detailed directory address
cd folder name (cd space plus folder name, enter the beginning and click the Tab key to automatically complete) Jump directory to folder
to you View the memory, name, date, etc. occupied by the files in the directory, and the folder displays DIR
cls Clear screen
exit drop out

By the way, introduce the commonly used shortcut keys in IDEA

hot key Features
Ctrl+Space Give a hint
Ctrl+Y Delete the line where the cursor is
Ctrl+D Copy the current line and insert it under the cursor position
Ctrl+Alt+L Format code
Ctrl+/ Make a single line comment on this line, and then press cancel
Ctrl+Shift+/ Make a multi-line comment on the selected block, then press cancel
Alt + Enter Automatic code correction
X holes Automatically generate a for loop executed X times, counted by i

When we directly enter Java at this time, we will find that "'Java' is not an internal or external file nor an executable command". Why is that? Because the system does not find the Java.exe file, it can't be executed (at least according to my installation The steps failed to run successfully, it is said that the minor version is different).
However, if we cd to the bin folder of the JDK and perform the same operation, we will find that a long list of content is displayed (many lines, and the content displayed is different for different versions). At this time, Java.exe runs successfully. Why is this?

Because the system searches for programs and files, there is a certain path rule.
The relevant content is introduced in detail below.

Set JAVA_HOME

In general, JAVA_HOME is to make a home for the JDK, let the system know where the JDK "lives", used to define "path" and "classpath". Due to the development, the JDK may need to be updated and upgraded. At this time, we only need to change the "address" specified by JAVA_HOME, and there is no need to repeatedly modify the "path" and "classpath". Set it here as the installation path of the JDK. Note that you can go to the upper level of the bin folder for details.

Set path

"Path" is the path the system searches for the exe file. We right-click this computer (also called computer or my computer), click properties, click advanced system settings, select advanced, click environment variables, and find the "path" in the system environment variables. It should be noted that the win system is more than one For the user's system, for the convenience of use, we directly set the system environment variables, create a new input %JAVA_HOME%\bin, where %JAVA_HOME% represents the path set before.
At this time, open the cmd window and enter java, then java.exe can be automatically run in any directory.

Set classpath

Regarding "classpath", those who have never used the cmd command prompt but directly use the integrated development environment may not be so familiar, nor do they know what this is for.

We know that "path" is the search path, which is relative to .exe. Similarly, "classpath" is the search path for .class files. If you use IDEA, you can ignore this step.

But we know that there is still a major version update after Java, that is, the update of Java9. Java9 has a new feature called Jshell, which is convenient for us to use the CMD command prompt to facilitate the execution of some lightweight codes.

Since our laboratory, including many companies, recommend the use of Java8 JDK, generally speaking, this function is not available. At this time, we need to configure the relevant path so that we can simulate the function of Jshell through the CMD window.

Generally speaking, "classpath" is the search path of .class classes. To use the compiled classes, the premise is of course that they can be found. JVM searches for classes through CLASSPTH. We need to set dt.jar and tools.jar in the lib subdirectory of the jdk installation directory to the CLASSPATH. Of course, the current directory "." must also be added to this variable.

When we need to simulate the function of Jshell, open a notepad, modify the suffix to .java, enter the code to save, enter cmd enter in the upper directory, enter javac class name.java enter, and then enter java class name enter, You can run the code. Seeing that the real role of classpath has not yet been discovered here, we close all windows and directly start the CMD window. You will find that the current directory is C:\User\ username, type dir and press Enter. It is found that there is no file with the suffix of .class, but if we run it through the java class name, we will find that it can run, that is, the computer can find this class file. By setting the "classpath", we can run the .class file directly without opening IDEA, building a project and building a module and package. Although the performance is still far inferior to Jshell, compared to adjusting the path every time , I think it is a great simplification.
It's useful anyway, but it's useless



to sum up

The above is the thinking of the first course of the winter vacation camp, and some of my own thoughts.

Guess you like

Origin blog.csdn.net/weixin_52292970/article/details/113107225