About java java basis of (a)

Introduction ...

SUN Java was first used by the company (already acquired by Oracle) of James Gosling (high commander, known as the father of Java) in the early 1990s, a programming language developed in the last century, was originally named Oak, the goal is for small embedded applications, home appliances, the results of the market nothing response. Mended rise of the Internet, let Oak renewed vigor, so the transformation of the company SUN Oak, the Java name released in 1995, because Oak has been registered, so the Java SUN registered trademark. With the rapid development of the Internet, Java has become the most important network programming language.

Java between compiled languages ​​and interpreted languages. Compiled languages ​​such as C, C ++, the code is compiled into machine code directly executed, but the different platforms (x86, ARM, etc.) CPU instruction set different, and therefore, needs to be compiled machine code corresponding to each of the platforms. Interpreted languages ​​such as Python, Ruby does not have this problem, the source code can be directly loaded and run by an interpreter, the cost of operating efficiency is too low. The Java code is compiled into a "byte code", which is similar to abstract CPU instructions, then, to prepare virtual machines for different platforms, different platforms of the virtual machine is responsible for loading bytecode and executed, thus achieving a "once preparation, running everywhere "effect. Of course, this is for Java developers,. For virtual machines, you need to be developed separately for each platform. In order to ensure that different platforms, different companies developed the virtual machine can execute Java byte code correctly, SUN company developed a series of Java Virtual Machine Specification. From a practical point of view, JVM's done a very good compatibility, low version of Java byte code can run on a normal high version of the JVM.

With the development of Java, SUN Java and to the separation of the three different versions:

  • Java SE:Standard Edition

  • Java EE:Enterprise Edition

  • Java ME:Micro Edition

So what does it matter between the three?

┌───────────────────────────┐
│Java EE                    │
│    ┌────────────────────┐ │
│    │Java SE             │ │
│    │    ┌─────────────┐ │ │
│    │    │   Java ME   │ │ │
│    │    └─────────────┘ │ │
│    └────────────────────┘ │
└───────────────────────────┘

In short, Java SE is the standard version, including the standard JVM and standard libraries, and Java EE Enterprise Edition, it is only on the basis of Java SE API and adding a large number of libraries, in order to facilitate the development of Web applications, databases, messaging services, Java EE application using a virtual machine and Java SE identical.

Java ME and Java SE on different, it is a for embedded devices "slimmed", Java SE standard library can not be used on Java ME, Java ME virtual machine is "thin version."

There is no doubt, Java SE is the core Java platform, Java EE and Web applications are for further study necessary. We are familiar with the Spring framework and other open-source Java EE are part of the ecosystem. Unfortunately, Java ME has never really caught on, but Android development is one of the criteria to become a mobile platform, therefore, no special needs, do not recommend learning Java ME.

Recommended Java learning roadmap is as follows:

  1. First, learn Java SE, master Java, Java core development technology and the use of language itself Java standard library;

  2. If you continue to learn Java EE, Spring Framework so, database development, distributed architecture is the need to learn;

  3. If you want to learn big data development, then Hadoop, Spark, Flink these big data platform is the need to learn, they are based on Java or Scala development;

  4. If you want to learn mobile development, then the in-depth Android platform, Android App Development grasp.

No matter how choose, the core technology is the foundation of Java SE, the purpose of this tutorial is to make you completely proficient in Java SE!

Java version

From the 1995 release of version 1.0, so far, the latest version of Java is Java 13:

time version
1995 1.0
1998 1.2
2000 1.3
2002 1.4
2004 1.5 / 5.0
2005 1.6 / 6.0
2011 1.7 / 7.0
2014 1.8 / 8.0
2017/9 1.9 / 9.0
2018/3 10
2018/9 11
2019/3 12
2019/9 13

Java version of this tutorial are using the latest version of Java 13 .

Glossary

Beginners learn Java, often heard JDK, JRE these terms, which in the end is what?

  • JDK:Java Development Kit
  • JRE:Java Runtime Environment

Simply put, JRE is to run the Java Virtual Machine bytecode. However, if only the Java source code to be compiled into Java byte code, it needs JDK, because in addition to JDK includes JRE, also provides compilers, debuggers, and other development tools.

Relationship between the two is as follows:
  ┌─    ┌──────────────────────────────────┐
  │     │     Compiler, debugger, etc.     │
  │     └──────────────────────────────────┘
 JDK ┌─ ┌──────────────────────────────────┐
  │  │  │                                  │
  │ JRE │      JVM + Runtime Library       │
  │  │  │                                  │
  └─ └─ └──────────────────────────────────┘
        ┌───────┐┌───────┐┌───────┐┌───────┐
        │Windows││ Linux ││ macOS ││others │
        └───────┘└───────┘└───────┘└───────┘

To learn Java development, of course, you need to install the JDK.

That JSR, JCP ...... is what?

  • JSR规范:Java Specification Request
  • JCP organization: Java Community Process

In order to ensure regulatory Java language, SUN companies engage in a JSR specification, those who want to add a Java platform features, such as the ability to access the database, you must first create a JSR specification that defines a good interface, so that the various database vendors in accordance with specifications write Java driver, developers do not have to worry about writing code on the MySQL database can run, do not run on PostgreSQL.

Therefore, JSR is a set of specifications from the JVM memory model program interface to the Web, all standardized. The organization is responsible for auditing the JSR JCP.

When you publish a JSR specification, in order to allow everyone to have a reference, it would also publish a "reference implementation", and a "compatibility test suite":

  • RI:Reference Implementation
  • TCK:Technology Compatibility Kit

For example, it was proposed to engage in a news server-based Java development, this proposal ah well, but the proposal is not enough light there, have posted really run the code, which is RI. If there are other people who want to develop such a message server, how to ensure that the message server for developers interfaces, functions are the same? So we have provided TCK.

Generally speaking, RI just a "run" the correct code, it is not the pursuit of speed, so, if you really want to choose a Java message servers, usually no one with RI, we will choose a competitive commercial or open source products.

Reference: Java Message Service JMS of JSR: https://jcp.org/en/jsr/detail?id=914

 

Installation jdk

Search JDK 13, to ensure that from Oracle's official website JDK download the latest stable version:

 

 

Set Environment Variables

After installing the JDK, you need to set an JAVA_HOMEenvironment variable that points to the JDK installation directory. In Windows, it is the installation directory, like this:

D:\sorfTools\jdk13\install

 

 Then, JAVA_HOMEthe bindirectory to the system environment variables PATHon. In Windows, it is a long way:

%JAVA_HOME%\bin

 

 To JAVA_HOMEthe binadd directory to PATHthe order can be run in any folder java. Open a command prompt, enter the command java -version, if all goes well, you will see the following output:

 

 If you see the following results: 

 

 This is because the Java virtual machine system can not findjava.exe , you need to check to check the configuration JAVA_HOME and PATH

You can refer to how to set or change the PATH system variable .

Related information JDK folder

Careful shoes can also JAVA_HOMEa binfind a lot of executable files directory:

  • java: This executable is actually a JVM, a Java program to run, is to start the JVM, then let the JVM perform the specified code compiler;
  • javac: This is a Java compiler, which is used to Java source files ( .javaend extension) is compiled into Java byte code files ( .classend extension);
  • jar:用于把一组.class文件打包成一个.jar文件,便于发布;
  • javadoc:用于从Java源码中自动提取注释并生成文档;
  • jdb:Java调试器,用于开发阶段的运行调试。

编码工具 IDE的使用

IDE是集成开发环境:Integrated Development Environment的缩写。

使用IDE的好处在于按,可以把编写代码、组织项目、编译、运行、调试等放到一个环境中运行,能极大地提高开发效率。

IDE提升开发效率主要靠以下几点:

  • 编辑器的自动提示,可以大大提高敲代码的速度;

  • 代码修改后可以自动重新编译,并直接运行;

  • 可以方便地进行断点调试。

目前,流行的用于Java开发的IDE有:

Eclipse

Eclipse是由IBM开发并捐赠给开源社区的一个IDE,也是目前应用最广泛的IDE。Eclipse的特点是它本身是Java开发的,并且基于插件结构,即使是对Java开发的支持也是通过插件JDT实现的。

安装Eclipse

Eclipse的发行版提供了预打包的开发环境,包括Java、JavaEE、C++、PHP、Rust等。从这里下载:

我们需要下载的版本是Eclipse IDE for Java Developers:

 

 

设置Eclipse

下载并安装完成后,我们启动Eclipse,对IDE环境做一个基本设置:

选择菜单“Eclipse/Window”-“Preferences”,打开配置对话框:

eclipse-pref

我们需要调整以下设置项:

General > Editors > Text Editors

钩上“Show line numbers”,这样编辑器会显示行号;

General > Workspace

钩上“Refresh using native hooks or polling”,这样Eclipse会自动刷新文件夹的改动;

对于“Text file encoding”,如果Default不是UTF-8,一定要改为“Other:UTF-8”,所有文本文件均使用UTF-8编码;

对于“New text file line delimiter”,建议使用Unix,即换行符使用\n而不是Windows的\r\n

Java > Compiler

将“Compiler compliance level”设置为13,本教程的所有代码均使用Java 13的语法,并且编译到Java 13的版本。

去掉“Use default compliance settings”并钩上“Enable preview features for Java 13”,这样我们就可以使用Java 13的预览功能。

Java > Installed JREs

在Installed JREs中应该看到Java SE 13,如果还有其他的JRE,可以删除,以确保Java SE 13是默认的JRE。

Eclipse IDE结构

打开Eclipse后,整个IDE由若干个区域组成:

eclipse-workspace

  • 中间可编辑的文本区(见1)是编辑器,用于编辑源码;
  • 分布在左右和下方的是视图:
    • Package Exploroer(见2)是Java项目的视图
    • Console(见3)是命令行输出视图
    • Outline(见4)是当前正在编辑的Java源码的结构视图
  • 视图可以任意组合,然后把一组视图定义成一个Perspective(见5),Eclipse预定义了Java、Debug等几个Perspective,用于快速切换。
新建Java项目

在Eclipse菜单选择“File”-“New”-“Java Project”,填入HelloWorld,JRE选择Java SE 13

new-java-project

暂时不要勾选“Create module-info.java file”,因为模块化机制我们后面才会讲到:

new-java-project-2

点击“Finish”就成功创建了一个名为HelloWorld的Java工程。

新建Java文件并运行

展开HelloWorld工程,选中源码目录src,点击右键,在弹出菜单中选择“New”-“Class”:

new-java-class

在弹出的对话框中,Name一栏填入Hello

new-hello-class

点击”Finish“,就自动在src目录下创建了一个名为Hello.java的源文件。我们双击打开这个源文件,填上代码:

hello-java-source

保存,然后选中文件Hello.java,点击右键,在弹出的菜单中选中“Run As...”-“Java Application”:

run-as-java-application

Console窗口中就可以看到运行结果:

console

如果没有在主界面中看到Console窗口,请选中菜单“Window”-“Show View”-“Console”,即可显示。

 

IntelliJ Idea

IntelliJ Idea是由JetBrains公司开发的一个功能强大的IDE,分为免费版和商用付费版。JetBrains公司的IDE平台也是基于IDE平台+语言插件的模式,支持Python开发环境、Ruby开发环境、PHP开发环境等,这些开发环境也分为免费版和付费版。

Guess you like

Origin www.cnblogs.com/JonaLin/p/12121648.html