Setup and use of development environment

Download and install development tools

  • Download the way

    Method 1: Download it from www.sun.com www.oracle.com

    Method 2: Search and download www.baidu.com

  • installation

    If you download the installation version, click Next to install all the way.

    If the download is green version, you can directly decompress;

    No matter the installation version or green version, remember not to have Chinese in the installation path!

JDK directory structure

  • Bin directory – This directory is used to store various JDK tool commands.
  • Conf directory – This directory is used to store JDK configuration files.
  • Include directory – this directory contains header files for some platforms.
  • Jmods directory – This directory mainly houses various JDK modules.
  • Legal directory – This directory contains authorization documents for various JDK modules.
  • The lib directory – this directory contains supplementary JAR packages and source code for JDK tools.

Related concepts

  • JDK – called Java Development Kit. Java developers need to download and install the JDK, which is currently the dominant version, JDK11.
  • JRE – called Java SE Runtime Environment (Java SE Runtime Environment), provides the software Environment necessary to run Java applications. It is a must for both developing and running Java applications.
  • Javac.exe – a compiler used to translate high-level Java source code into bytecode files.
  • Java.exe – interpreter, mainly used to start the JVM to interpret and execute bytecode files.

The relationship between JDK, JRE, and JVM

Common tools for Java development

  • Text Editor (TE, Text Editor)
  • Notepad, Notepad++, Edit Plus, UltraEdit…
  • Integrated Development Environment (IDE)
  • Jbuilder, NetBeans, Eclipse, MyEclipse, IDEA,…

The process of writing Java programs

  • Create a text document and change the file name extension from XXX.txt to xxx.java.
  • Use notepad /Notepad++ to open the file, write Java code and save;
  • Start the DOS window and switch to the path where the. Java file is located.
  • Using javac XXx. Java to compile, generate xxx.class bytecode files;
  • Use Java XXX for interpretation and execution, print the final results;

Common Mistakes

  • Error: need class,interface or enum => usually all class keyword misspellings
  • Error: Symbol not found => Usually due to spelling errors or words that are not supported in Java
  • Error: need ‘; ‘=>’ is usually because of the missing semicolon, plus because of the version of the semicolon can be
  • Error: Invalid character :’\uff1b’ =
  • Error: The main method cannot be found in PrintTest class, please define main as: => main instead of mian

Compile and run

Simplified compilation and execution of new Java11 features

  • Create a text document and change the file name extension from XXX.txt to xxx.java.
  • Use notepad /Notepad++ to open the file, write Java code and save;
  • Start the DOS window and switch to the path where the. Java file is located.
  • Java xxx. Java to compile and run, print the final results;

Common shortcut keys

  • CTRL + s to save
  • CTRL + c to copy
  • CTRL + v to paste
  • CTRL + a selection
  • CTRL + x shear
  • CTRL + z
  • CTRL + f search

annotation

// Single-line comments, starting with // and ending with this line, are comments.

/* */ multi-line comments, starting with /* and ending with */.

/** */ multi-line/document comment, starting with /** and ending with */, is a comment that supports extraction.

  • Multi-line comments are not allowed to be nested!

Cross-platform principle

  • Java bytecode can be translated by the JVM into machine instructions that specific platforms can execute. It was Sun who defined the JVM specification, and different operating systems mostly provided JVM implementations, that allowed the same bytecode files to run on different systems, earning Java the reputation of “compile once, use everywhere.”