Home  >  Article  >  Java  >  Basic knowledge of java + environment construction and variable configuration

Basic knowledge of java + environment construction and variable configuration

伊谢尔伦
伊谢尔伦Original
2016-11-26 09:24:021113browse

1. DOS command

Software: It is a collection of computer data and instructions organized in a specific order.

Interaction mode: graphical interface, command line

dir directory displays files and subdirectories

cd change directory changes the current path (enter the specified directory)

md make directory creates a new subdirectory (folder)

rd remove directory Delete a subdirectory (folder)

cd.. Return to the previous folder

cd/ Return to the root directory (disk)

del delete Delete files (without going to the Recycle Bin) del *.txt (delete a certain file) All txt files in the directory)

ren rename

Note:

rd Delete a subdirectory (folder) (make sure there are no files in the directory. If there are files, directly using the "rd directory" command will not work. At this time, you can execute the del command on the directory, and then use the rd command to delete the directory. The advantage of this is that you do not need to change the path back and forth)

For example: There is a text document 1.txt under C:abcop, and you want to delete the op folder

Method 1:

First delete the text document C:abcop>del 1.txt

Back to abc The command

C:abc>del op will prompt to delete the files in the directory OK

C:abc>rd op

Complete deletion of the op directory, which is simpler than method 1

II. Java language overview

1. Java is a language that allows users to transfer applications from a remote server to a local machine through the Internet and execute them.

Features: Object-oriented, safe and reliable, independent of platform (operating system), portability

Principle: Just install a Java Virtual Machine JVM (Java Virtual Machine) on the platform that needs to run Java programs, and the JVM will do it Parse and execute Java run. (Virtual machines have different versions according to the operating system)

2. Three technical architectures of java language:

J2EE Enterprise Edition: It is a solution for developing applications in enterprise environments, technology Server Jsp Wait

J2SE Standard Edition: It is a solution provided for the development of ordinary desktop and morning applications, and can complete the development of some desktop applications.

J2ME Small Edition: A solution provided for the development of electronic consumer products and embedded devices. Mainly used in mobile applications.

The name was changed to JavaEE after Java 5.0. .

3. Environment construction

Download, install JRE, JDK, and configure environment variables.

JRE: Java Runtime Environment Java runtime environment, including Java virtual machine and core class libraries required for Java

Basic knowledge of java + environment construction and variable configurationJDK: Java Development Kit Java development package, including development tools and JRE, and the development tools include the compilation tool javac .exe, packaging tool jar.exe, etc.

1. Why does JDK include JRE?

First: Always run the developed program to see the effect;

Second: The development tools in the bin directory under the JDK are written in Java, and they need the support of the running environment virtual machine when running

2. Why do we need to do it? Java environment variable configuration

After installing the JDK, use the command line to enter the lib and execute the javac.exe program in the lib,

F:jdk1.6.0_24lib>javac. At this time, if you exit to the JDK F:jdk1 .6.0_24lib>cd.., and then execute javac.exe at this time, F:jdk1.6.0_24>javac will not succeed.

Question: Do I need to go to the lib directory every time I develop a program? The requirement is that commands can be executed in any directory.

The answer is: tell the system the path where the command tool is located, and let the system find it. It is more convenient to use the command, that is, java environment variable configuration.

3. Configuration skills

Sometimes the drive letter or name of jdk will be changed. Every time it is changed, it must be changed in the path to prevent misoperation to other configurations. You can use a configuration skill:

(1) use A new environment variable a to record the changed drive letter and file name: java_home=F:jdk1.6.0_24

(2) Get the value of a in path, and add the unchanged bin path=%java_home%bin

Note: The %% symbol is to dynamically obtain the value of an existing environment variable, so you only need to change the variable value. 4. Temporary configuration of environment variables

Use the dos set command (view or set Environment variable value)

C:>set path View the value of path

C:>set path=haha Set the value of path

At this time, the path value is haha, but open a dos again in the "Start" menu The window set path is still the previous value.

This means that the way to configure environment variables in dos is only valid in the current window. However, if you use the start command to open a new DOS window after configuration, this window will inherit the environment variable value of the original window.

In this configuration, the previous value of path is gone, only the newly configured one. What if you want to add a new value based on the path environment variable value?

You can use dynamic access to variable values: C:>set path=haha;%path%

Four. Hello World composition

Keywords: words given special meaning by the Java language, such as the class keyword that specifically defines classes , keywords can only be lowercase

1. Java writing standards

a. Class names must be meaningful words to increase readability

b. Class names consist of single letters, and the first letter of each word is capitalized

c , Braces define the class name interval

d. The content in the class must have a sense of ladder (often use the tab key)

e. All methods must end with;

2. Fixed main function writing method public static void main(String [] args){}, to ensure the independent operation of the class, why?

Because the java command will call the virtual machine, the virtual machine will use the low-level content of Windows and run the specified class. In the class, it will first find the specified function main and run it. That is to say, the virtual machine calls the main function in the class we specify and executes the code. The main function is the entrance to a program, ensuring that the class runs independently. Whichever class needs to be run, write the main function in it.

5. Java Document Comments

javadoc.exe in JDK can extract all the document comments in the program into a web page. This web page is the instruction manual of the written program.

1. The expression form of document comments: /**    */ is unique to java

In comments: // is used in a single line, /* */ is used in multiple lines, and there cannot be more than one in a multi-line comment Line comments can have single-line comments. These two comments will not be interpreted and executed by the JVM

2. Purpose of comments: 1. Comment description 2. Debugging the program

When writing a program, you should develop the habit of commenting frequently. Sort out your thoughts through comments first, and then use code to reflect them, because code is just a manifestation of thoughts.

When writing a new program:

1. Write notes first: a. Needs, requirements b. Ideas c. Steps


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn