java development foundation




A , prelude

Before learning the Java language, you have to have some common dos command, such as:

dir : lists files and files in the current directory folder

md : Create a directory (folder)

RD : delete the directory

cd : Enter the specified directory

.. cd : Exit the current directory, to return to the parent directory

cd \ : return to the root directory

del : delete files

* del : delete all files

. del * File extension: Delete the same type of file

Exit : Exit dos command line

echo : Create a file. Such as: echo I could (here is the file contents)> Can I .txt

CLS : clear screen

Help : displays all commands and description

Exit : Close

     Note: When you delete with the command line dos rd in the folder, the folder must ensure that there is no file, then you can delete individual files inside, you can also use the + del ways folder delete all the files inside.

          Tip: When we want to enter a directory, and a long directory name, such as: a directory called woshiheimachengxuyuan, we can use cd woshi *, a * instead of behind the text shorthand way to fast efficiency.

Two,  the Java language environment to build 

     JRE : Java Runtime Environment Java Runtime Environment shorthand, including the Java Virtual Machine JVM needed for Java programs and core class libraries , etc., as too want to run a Java program to develop good, as long as the computer can be installed JRE.

     The JDK : Java Development Kit Java Development Kit shorthand, JDK is available to Java developers, which contains the Java development tools , also includes the JRE . So install the JDK, you do not have to install the JRE alone. Development tools which include: Compilation Tools (javac.exe) and packaging tools (jar.exe) and so on.

     In short, JDK includes the JRE, JRE included JVM, JDK developed using java program, to the JRE to run.

Why JDK contains a JRE it? First, the development of the complete program, you need to run it and see the effect, just as you need to run the exe file in the windows environment.     Second, and most important, JDK in development tools (such as javac.exe, java.exe, etc.) are actually applications written in the Java language, for convenience only packaged into exe file, if there is no JRE, then these tools It can not run.
    

      to sum up:

           JRE: JVM + class library (java library)

           JDK: JRE + JAVA development tools


      Configure environment configuration:

            Let the tool under the java jdk \ bin directory, you can run in any directory, reason is the directory where the tool to tell the system when using the tool, by the system to help us find the specified directory.

      Environment variable configuration:

        A : permanent configuration: the JAVA_HOME = % installation path % \ the Java \ JDK

                        path=%JAVA_HOME%\bin

        B : Temporary configuration: set path =% path%; C: \ Program Files \ Java \ jdk \ bin

Features: The system default program to go to find the current path to be executed, and if not, go down the path set in the path to find.

     classpath configuration:

       A : permanent configuration: classpath = .; c: \; e: \

       B : Temporary configuration: set classpath = .; c: \ ; e: \

Note: When you define an environment variable classpath, notable situations

If you do not define an environment variable classpath, java after the start jvm, looks for class files to run in the current directory;

If the classpath is specified, you will find the class file to run in the specified directory.

Also in the current directory to find it? Two cases:

1 ): If the value at the end of the classpath semicolon, no classes running to find specific path, it will find a default in the current directory.

2 ): If the value of the classpath is not the result of a semicolon, no classes running to find the specific path, the current directory will not find.

Generally do not specify a semicolon, if not find the class file to run in the specified directory on the error, so you can debug the program.

 

Three, javac java command and command to do something?

     To know java is divided into two parts: one compiled a run.

     javac:负责的是编译的部分,当执行javac时,会启动java的编译器程序。对指定扩展名的.java文件进行编译。 生成了jvm可以识别的字节码文件。 也就是class文件,也就是java的运行程序。

      java:负责运行的部分.会启动jvm.加载运行时所需的类库,并对class文件进行执行.

一个文件要被执行,必须要有一个执行的起始点,这个起始点就是main函数.

注释


    注释的作用:1、注解、说明、解释我们的程序,提高代码的阅读性。;

                2、调试程序。例如程序出现错误,可以例如注释来查找出错的地方。

    有三种注释方式:单行注释、多行注释、文档注释。

    单行注释://注释文字

    多行注释:/*-------中间可以有多行注释文字-------*/  注:多行注释不要嵌套多行注释。

    文档注释:是Java特有的注释,通常书写在类、域、构造函数、方法、定义之前。注释内容可以被JDK中的工具javadoc.exe所解析,格式为 javadoc -d 存的文件夹  类名.java 生成一套以网页文件形式体现的该程序分说明文档。格式:例

    /**

    作者:

    版本:

    作用:

    等

    */

    初学者应该养成写注释的习惯,先写需求,在写分析,因为代码仅仅是思想的一种体现形式而已。将自己的思想通过注释先整理出来,再用代码去体现,不要每行都加注释,也不要每行都不加注释,加有意义的注释。

入门程序:

运行后









        

发布了26 篇原创文章 · 获赞 19 · 访问量 4万+

Guess you like

Origin blog.csdn.net/a23006239/article/details/46910331