Java Learning Notes series — Sun Bujian 1208

【 Detail + super basic 】Java- Learning Notes 01

【 Detail + super basic 】Java- Study Notes 02

Ongoing updates….

First, Java overview

Example code:

public  class Test {
	public  static void main(String [] args){
    	System.out.println("Hello world"); }}Copy the code

JAVA profile

Java is a semi-compiled and semi-interpreted language, which compiles.Java source files into bytecode files with a.class extension. The bytecode files can be run on any OPERATING system running the JVM virtual machine.

Java features: simple object-oriented, distributed, interpretable, robust, secure, structurally neutral, portable, efficient, multi-threaded, dynamic and cross-platform programming language.

Three Java platform standards: Java SE4 (Standard edition: for developing desktop applications) Java EE (Enterprise edition: for developing and deploying server-side applications) Java ME (mobile edition: obsolete by Android, IOS, and Hong Kong OS).

The JDK installation

JDK: Java development kit

JRE: Indicates the Java runtime environment

JVM: Java virtual machine

In the JDK installation directory, there is a JRE directory, which contains two folders, bin and lib. In this case, you can think of bin as the JVM, and lib as the class libraries that the JVM needs to work. The JVM and lib together are called jre.

The three relations

simply

Configuring the development Environment

jdk-8u271-windows-x64

  • Path: Specifies the Path to save the executable files (such as java.exe and javac.exe) of the operating system. Example: C:\JDK1.8\bin

  • Classpath: Specifies the directory where the bytecode file resides (the JVM needs to go to the directory set in the classpath to find the packages and classes to execute).

    • The value of the classpath variable is set above the package directory

    • Notifies the JVM user of the location of the classes, and the search between classes (dependent objects)

      Classpath is an environment variable used by the Javac compiler to tell the Java execution environment where to find the Java you want to execute. Environment variables are parameters used in an operating system to specify the environment in which the operating system runs, such as temporary folder locations and system folder locations

  • Java_home: Specifies the JDK installation directory. Example: C:\JDK1.8

The environment variable

  • Configure the environment variable JAVA_HOME

    • The value of the variable is the path of the installed JDK
    • C: \ ProgramFiles \ Java \ jdk1.8.0 _201
  • Configure the environment variable path

    • The variable value is the bin path of the installed JDK
    • C: \ ProgramFiles \ Java \ jdk1.8.0 _201 \ bin

Java program running

Create a Hello. Java file on drive D with the following contents:

public class Hello {
// The Java source file can have more than one class, but at most one public class (public class), and the source file name must be the same as the name of the public class.
    public static void main (String []args) {
    Public static void mian(String []args){} is the main() method.
    	System.out.println("hello world "); }}Copy the code

Java programs run the compiled run process

Java source files (.java files) are compiled by the Java compiler (Javac) into bytecode files (.class files) and run on the operating system through the Java virtual Machine.

Test using the command line

Win +R CMD Go to the command line

Use common Dos commands to reach the source file path

Switch drive letters: C: D: E: View all files in the current directory: dir Switch directory: CD (change directory):

Compile the source file: javac hello.java

Run the bytecode file: Java Hello

How to open CMD:
  • Start + system + command prompt
  • Win +R enter CMD to open the console (recommended)
  • In any folder, hold down the Shift key + right mouse click: Open the command line window from here
  • Add the CMD path to the front of the explorer address bar
  • (Run as administrator: at start search CMD, right click, and select Run as Administrator)
Attached: common Dos commands
  1. Drive letter switch: C: D: E:
  2. View the dir of all files in the current directory
  3. CD (change directory):
  • Cross-drive letter switch: CD + /d + file name;

  • Switch to the same directory:

    • Return to the directory above: CD..
    • Enter the desired directory CD + file name
  • Clear Screen: CLS (Clear Screen)

  • To exit a terminal, enter exit

  • Check the computer IP address: ipconfig

  • Very common Windows programs: Calculator (Calc), Notepad, Mspaint

  • Ping: Tests whether the network is normal

  • Create a folder: md + Folder name

  • To delete a folder: rd + folder name

  • Create a file: CD > File name. extension

  • Delete a file: del + file name

Welcome to subscribe column to invite you to drink a cup of Java, hope to bring convenience to friends in need, but also hope to get everyone’s attention and support.