White's 20 days learning Java punch day1

Taiyuan University of Technology robotics team 20 days to learn punch day1

Postponed because of school, I Ougan bored at home, but also coincides with punch card team organizes learning activities, it is a good opportunity to enhance their learning ability of self-supervise.
Before that I never had contact with Java, want to share study notes, can help to like me or a friend in need, review and organize the way, if the content is a problem, welcome to correct me
learning content: Java learning website: b station

Day0l

First of all, learning to complete the development of Java software programming language by then,

1. What is software?

The computer consists of two parts
hardware: mouse, keyboard, display, main internal chassis CPU, memory, hard drive, etc.
Note: The computer only the hardware is unable to work, the need for software-driven hardware to work
Software: software includes application software and system software
system software: direct interaction of hardware and software, such as window7, win8 operating system and other
application software: application software typically runs in the system software.
For example qq runs on windows operating system qq is the application software. win7 is the operating system software.

We usually refer to software development generally refers to the use of computer programming language to complete the "application software" development.

2, DOS command

Before learning Java, we must first grasp the basic DOS command windows related to [run in the Java compiler will use to] DOS Disk Operating System is the acronym for disk operating system. It is an operating system based disk management, including directory manipulation classes command, type the command disk operations, file operations classes and other commands. Specific orders not to say, can search the Internet

DOS command in a DOS window to write, then the DOS window opens where is it?

Start Menu - Run window - [Enter the default input cmd-- black command window open, this is a DOS command window]

3, the application on the Windows operating system file extensions

As a java programmer, after ending .java To create a new file, .java extension must be
careful not to hide file extensions.

4, Java loading and execution

* Run Java program consists of two very important stage

- compilation stage

- operational phase

* Compilation phase

- The main task compiles Java source stage is to check whether the Java syntax,

In line with normal Java syntax can be generated bytecode files (xxx.class)

Java does not comply with the rules of grammar can not generate bytecode files
on after bytecode files are explained

- byte code file is not a pure binary file that can not be performed directly in the operating system.

- compilation phase of the process:

* Programmers need somewhere hard drive (random location) .Java a new file name extension,

The file is called Java source file , the source file which is written in Java source code / source .

And this source is not at liberty to write, must comply with the Java syntax rules <Java syntax rules need to remember>

* Java programmers need to use JDK which comes javac.exe command to compile Java programs.

Javac how to use it? Where to use it?

-javac usage rules:

The original file path javac Java

-Javac command necessary to use the DOS command window reference point 2 .

javac Java compiler is a tool / command.

note: A java source file can be compiled to generate multiple .class files. Bytecode file / class file is the final document to be executed, so that after the class file generation, Java source file is deleted and will not affect the execution of Java programs. But generally do not remove the Java source code, because the class file the final implementation of the results may not be what we want (error), then this time need to go back and re-edit java source code, then recompile the Java source code to generate a new class file, and then run this class program that generates new effects.

* After the end of the compilation, you can copy the class files to other operating systems which run. 【Cross-platform】

* [Operational phase can in other operating systems, cross-platform]

Here twice mentioned cross-platform, Java language is a big advantage is that you can run cross-platform, then why did he cross-platform? Here do to add, by the way introduced JDK, JVM, JRE

After the code is compiled Java program code is not a hardware system that can be run directly, but rather a kind of "intermediate code" that is to say before the bytecode. Then install different Java Virtual Machine (JVM) on different hardware platforms, the code bytecode by the JVM to again "translated" into the corresponding hardware platform capable of executing. That Java does not run on the operating system, but runs on the Java Virtual Machine (JVM), JVM there are many, such as Windows correspondence, as well as the corresponding Linux, so that we do not need to change the code itself, but only need to use a different type of JVM can run on different operating systems.

* Description JDK, JVM, JRE

The JDK (Java Development Kid, open source Java Development Kit) is a product for Java developers of the JRE (Java Runtime Environment, Java Runtime Environment) is a collection of programs that must be run JAVA environment, including the JVM and Java core class standard implementation library the JVM (Java virtual Mechinal, Java virtual machine) is a part of the JRE, Java is the core part of the cross-platform software program capable of running Java language writing

In fact,
JDK = JRE + relationship between multiple Java development tools JRE = JVM + various libraries of these three is deeply nested JDK> JRE> JVM

Return to the question of how to run

After -JDK install, comes with a javac.exe addition, there are another tool / command called java.exe, java.exe command is responsible for the operational phase.

Where -java.exe use? how to use?

- Use the DOS window.

-Java.exe how to use it?

== java class name == What is the name of the class? For example there is a A.class on the hard disk, then A class is his name, later to understand the specific

- the operational phase of the process:

* Open a DOS command window

* Enter: java A

* Java.exe command starts the Java Virtual Machine (JVM), JVM will start class loader ClassLoader

* ClassLoader A.class search would go hard file, the file is found it is loaded into the JVM byte code file them.

* JVM byte code file will A.class interpreted as binary data such 1010101010.

* The operating system and the underlying hardware platform to perform binary interaction.

5, the start of the first Java program

First, we write the source code HelloWorld.java

public class HelloWorld{
	public static void main(String[]args){
		System.out.println("Hello World!");
	}
}

Direct copy, pay attention to case

* Then compile - use javac command

- Open a DOS command window, direct input javac, and then press Enter, the following:

		'javac' 不是内部或外部命令,也不是可运行的程序或批处理文件

Appear to be happening is because: windows operating system can not find the javac command file

- how to solve the above problem javac is not available?

We need to understand how to search for the windows operating system is the hard drive at a command it?

* First of all searches from the current directory

* Less than the current search directory, will search command from the environment variable path specified among

* If you can not search, it reported more errors.

Then we need to configure the environment variable path environment variables (environment variables) generally refers to some of the parameters used to specify the operating system running in the operating system environment *

Open Computer Properties - Advanced System Settings - Advanced - Environment Variables - find system environment variables path

Since the search command real path specified in the search, so just add the path to where javac system environment variables, the path between English separated by semicolons, then you can use the command javac

-javac commands how to use?

javac java source file path (absolute path, relative path can be) the absolute path: indicates that the path from a disk drive letter as the starting point of the path. Relative path: The path from the starting point of the path is currently located

If there .class file in the corresponding path, indicating the success of compiling occur, for example: HelloWorld.class

* After successful compilation run java program:

- need to use the command java.exe

- use

java class name

There HelloWorld.class on the hard disk, then the class name is HelloWorld

​ java HelloWorld

Must pay attention: with the java command is not behind the file path, is the name of a class.

- First you need to switch to the directory where the file HelloWorld.class first DOS window directory. Find the source files directly in the path bar to enter cmd

- and then directly execute: java HelloWorld

Appears HelloWorld! String instructions to run successfully.

summary

The first day is mainly to learn some basic concepts, methods, compile and run, and assay development environment lay the foundation for later learning

Published an original article · won praise 1 · views 123

Guess you like

Origin blog.csdn.net/weixin_45810398/article/details/104563964