Java basic notes-preparations before learning Java, basic notes learning java
In the next month, I will share my notes when studying JavaSE with you. I hope my notes will help you.
I will post an article every day, which is the essence of my learning of Java. Of course, I will modify every note carefully to make the knowledge point clearer and easier to understand.
Java knowledge points
Software: system software, Application Software
Interaction Mode:
Graphical Interface GUI = Graphical User Interface
Command Line CLI = Command Line Interface
Java is an Internet-Oriented Programming Language launched by SUN = Stanford University Network in 1995.
Three technical architectures of Java:
J2EE = Java 2 Platform Enterprise Edition
J2SE = Java 2 Platform Standard Edition
J2EE
Note: After Java 5 is changed to JAVASE, JAVAEE, and JAVAME
SUN has been acquired by ORACLE
JAVA is portable: you only need to write a JAVA program that can run on any platform, as long as the platform has a Java Virtual Machine (JVM = JAVA Virtual Machine.
JRE = Java Runtime Environment is called the java Runtime Environment
JRE = JVM + core class
To run a developed program, you only need to install JRE on the computer.
JDK = Java Development Kit is called Java Development Kit
JDK = JRE + Java development tool. That is to say, users only need to install JRE, and developers need to install JDK.
The bin directory is binary (binary). The bin in JDK stores java development tools.
WindowsDOS command:
Enter the edisk: e: Enter
Open the program and press enter for the file name. You can leave the file ". EXE" empty.
Dir (directory): displays the folder in the current directory
Cd (change directory): change the directory
Cd .. back to the upper-level directory
Cd XXX *: open the file whose prefix is XXX. If there are multiple files, open the first file.
Cd \: returns the root directory of the current disk.
Md (make directory): Creates a folder.
Rd (remove directory): delete a folder, but the folder must be empty. Otherwise, the folder cannot be deleted.
Del: delete an object
Del *. *: delete files that meet *. *.
Del *: delete all objects.
K) help: Display All commands
Help cd: view the Help of the cd command
L) cls: clear screen
M) javac-version: view the current JDK version
N). indicates the current path.
Environment Variable path
The purpose of configuring path is to use javac and java tools in any directory;
The purpose of configuring classpath is to run the. class file in any directory without adding the path of the. class file. (Only works at runtime)
In DOS, if you want to open a program in any directory, You need to configure the environment variable path.
If aaa is enabled under drive D, the system will first find it under drive D. If not, it will find it from the environment variable.
A) Right-click "my computer"-properties-advanced-Environment Variable-Add the folder directory where javac is located before path and add a semicolon.
B) build a java environment
C) download and install JDK
D) Configure Environment Variables
E) Enter javac-version Verification in CMD. If java information is displayed, the java environment is successfully set up.
Environment variable configuration skills
If the javac path is changed, the path in the path also needs to be modified. This will cause a problem. The path not only has the javac path, but also the path of other system programs, if you modify the path multiple times, the system program may be unable to run due to unintentional modification of the system path. To solve this problem, you need to customize an environment variable and store only the new environment variable name in the path. When the path changes, you only need to modify the new environment variable without modifying the system environment variable.
Note: To pack the environment variable name with % in path, it indicates that the environment variable name is not the path in %.
Note: The system looks for a program from the path, so try to place the new environment variable in the path header.
Configure temporary environment variables
Valid only in the current CMD window. The window becomes invalid once it is closed!
Debug the program on another computer, copy the JDK to the USB flash drive, and temporarily configure the environment variable, that is, the JDK path, in CMD.
All settings in the DOS window are temporary, and all settings in the visual window are permanent.
A) Set: view all environment variables
B) Set path: view the environment variable path
C) Set path = XXX: Set the environment variable path to XXX.
Note: overwrite the original value!
Set path = (equal light): Delete the environment variable path
Set path = XXXX; % path %: Add a new value based on the original value
Configure the environment variable classpath
The environment variable path stores the windows Executable File path, while the classpath stores the JVM executable file path, that is, the. class file path. When running a java file using the "java class name", you need to set classpath if you want to run the file globally without writing the path.
"Set classpath = XXX" and "Set classpath = XXX ;"
If a semicolon exists, the system first searches for the path specified by classpath. If no. class file is specified in the path, it searches for the current directory. If no semicolon exists, it is only found in classpath. If no semicolon exists, an error is returned.
Compile and run
Compile: Javac file name to generate a. class
Note: This class can be run on any machine with JRE, which reflects the portability of java.
Note: generate a file named "class name. class"
Run: java class name
Note: This class must have the main function; otherwise, NoSuchMethodError: main is reported.
Note: javac is a java compiler. When javac is called, The javac compiler is called to detect code errors and generate a. class file.
The "java class name" calls JVM and runs the program.