java Basics

JAVA BASIC USE

1.java cross-platform principle

java code can run in any platform:the priciple is the different operational system have different JAVA virtual machine that can realize cross-platform.

图片名称

2.JRE&JDK

JRE :java runtime environment,including JAVA virtual machine and core class libraries required at runtime

JDK:java code development kit,you must install JDK before your development.

  • compile kit:javac.exe
  • running kit:java.exe
图片名称

3.Downloading and installing JDK

you can download JDK in the official website of the oracle

all of the develop tools can be placed in same directory to manage more conveniently.

the common directories(this can help you understand other software's directory):

  • bin:this directory stores various JDK tool commands, java and javac are stored in this directory
  • conf:the configuration files of JDK.
  • include:the header files of the unique platform.
  • jmods:the modules of JDK.
  • legal:the authority documentation of modules of JDK.
  • lib:the supplementary package of JDK.
  • the rest of directory are the descriptive documentation.

4.Common Dos command

  • the name of disk: E:switch to E disk.
  • dir :view the content of the current path.
  • cd [directory] enter into the next directory.
  • cd .. :return to the parent directory.
  • cd directory1\directory2... :enter into multi-level directories.
  • cd \ :return to the root directory of current disk.
  • cls :clear the screen.
  • exit :exit the CMD.

5.PATH environment variable configuration

  • why we should config environment variable

java&javac command in the bin directory cannot run directly in terminal.we must enter into bin directory to run these commands.In order to simplify the use method of it,we should config environment variable.

  • how to config environment variable

  1. open advanced system settings in control panel.
  2. click "environment variable"and create a new configuration in the system variable(the name of variable is JAVA_HOME,the value is the installation directory of JDK).
  3. edit the Path's value of system variables.
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_112
JDK_HOME  : %JAVA_HOME%
JRE_HOME  : %JAVA_HOME%\jre
CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
PATH      : your-unique-entries;%JAVA_HOME%\bin (make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.
图片名称
图片名称

6.Running code in the terminal

  • the three steps of developing a java program:

    1. writing code in your patform
    2. compile codes--javac (command name)
    3. run codes--java (command name)
  • cmd steps:

    1. build file:xxx.java,writing code in your notepad.
    2. open cmd,enter into the directory of xxx.java,compile this file and get class file.(command:javac hello.java)
    3. run xxx.java(java hellio)It's okay without a suffix
图片名称

7.How to kill BUGS

recognize BUG,analyze BUG,solve BUG

8.Installing and using NotePad

8.1 Open the Notepad++ website. Go to https://notepad-plus-plus.org/ in your browser.

8.2 Click download. This tab is on the upper-left side of the page

图片名称

you should notice in your configuration:

  • set your default coding language.
图片名称
  • you can run java code in a windows terminal.
javac HelloWorld.java  //compile the java code
java Helloworld    //run the java code

tip:you can use Tab key to auto-completion in a terminal

posted @ 2023-07-13 20:49  PostMan_Zc  阅读(7)  评论(0编辑  收藏  举报