• 主页
  • 相册
  • 随笔
  • 目录
  • 存档
Total 244
Search AboutMe

  • 主页
  • 相册
  • 随笔
  • 目录
  • 存档

Java-Overview

2020-06-11

1. 特性

Java is a platform-independent language: The programs written in Java language, after compilation, are converted into an intermediate level language called the bytecode which is a part of the Java platform irrespective of the machine on which the programs run. This makes java highly portable as its bytecodes can be run on any machine by an interpreter called the Java Virtual Machine(JVM) and thus java provides ‘reusability of code’.

Java是一种独立于平台的语言。用Java语言编写的程序,经过编译后,被转换成一种叫做字节码的中间级语言,它是Java平台的一部分,无论程序在哪台机器上运行。这使得java具有很强的可移植性,因为它的字节码可以通过称为Java虚拟机(JVM)的解释器在任何机器上运行,因此java提供了 “代码的可重用性”。


Java is a multithreaded language: Java can perform many tasks at once by defining multiple threads. For example, a program that manages a Graphical User Interface (GUI) while waiting for input from a network connection uses another thread to perform and wait’s instead of using the default GUI thread for both tasks. This keeps the GUI responsive.

Java是一种多线程语言。Java可以通过定义多个线程同时执行许多任务。例如,管理图形用户界面(GUI)的程序在等待网络连接输入时,会使用另一个线程来执行和等待,而不是使用默认的GUI线程来执行这两个任务。这样可以保持GUI的响应性。


Java programs can create applets


Java is an object-oriented programming language

2. 环境

JVM、JRE和JDK三者都是依赖于平台的,因为每个操作系统的配置都不一样。但是,Java是独立于平台的

  • JDK(Java Development Kit) : JDK is intended for
    software developers and includes development tools such as the Java
    compiler, Javadoc, Jar, and a debugger.
  • JRE(Java Runtime Environment) : JRE contains the
    parts of the Java libraries required to run Java programs and is
    intended for end users. JRE can be view as a subset of JDK.
  • JVM: JVM (Java Virtual Machine) is an abstract
    machine. It is a specification that provides runtime environment in
    which java bytecode can be executed. JVMs are available for many
    hardware and software platforms.(它是一个提供运行时环境的规范,在其中可以执行java字节码。JVM可用于许多硬件和软件平台。)

2.1. 安装

1
2
3
4
5
6
sudo apt-get install openjdk-11-jdk

echo $JAVA_HOME
echo 'export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"' | sudo tee -a "/home/usrname/.zshrc"
echo 'export PATH=$PATH:$JAVA_HOME/bin' | sudo tee -a "/home/usrname/.zshrc"
echo $JAVA_HOME

3. hello world

1
2
3
4
5
6
7
8
9
class HelloWorld 
{

public static void main(String args[])
{

System.out.println("Hello, World");
}
}
1
2
3
4
5
$javac HelloWorld.java
$ls
HelloWorld.class helloworld.java
$java HelloWorld
Hello, World
  • 源文件名:源文件名必须和类名相同。当保存文件的时候,你应该使用类名作为文件名保存(切记 Java 是大小写敏感的),文件名的后缀为 .java。(如果文件名和类名不相同则会导致编译错误)。
  • 主方法入口:所有的 Java 程序由 public static void main(String[] args) 方法开始执行。

4. 参考

  • Java Programming Language - GeeksforGeeks
  • Program Language
  • Java
  • Basic
高性能mysql-1
nginx配置笔记
  1. 1. 1. 特性
  2. 2. 2. 环境
    1. 2.1. 2.1. 安装
  3. 3. 3. hello world
  4. 4. 4. 参考
© 2024 何决云 载入天数...