java environment configuration and the second a Java program

1. Develop Java preparations

Configuration 1.1java development environment

1.1.1jdk Profile

  • JDK is the Java language software development kit, mainly for java applications on mobile devices, embedded devices. JDK entire java development of the core, which contains the JAVA runtime environment (JVM + Java system class library) and JAVA tools
  • Java Runtime Environment, referred to as the JRE that he is a necessary condition to run the program.
  • Core Java running jvm virtual machine, also contain other class loader, bytecode verifier and the like. ** JRE also contains other environmental support to run java program.
  • If you only run Java programs, as long as the installation of JRE without having to install the JDK .
  • orzcle put Java into Java SE (Standard Edition), Java EE (Enterprise Edition), Java ME (miniature version).
  • jdk Download https://www.oracle.com/technetw![2019-07-24_195744](D:\temp\2019-07-24_195744.png)ork/java/javase/downloads/index.html

1.1.2 configuration environment variable

  • In order to open  the My Computer Properties Advanced system settings Advanced Environment Variables System Variables

 

 

1.1.3新建下列3个变量名和变量值

JAVA_HOME

"C:\app\JDK-11.0.1"(JDK的安装目录)

CLASSPATH

.(当前目录)

PATH

%JAVA_HOME%\bin;.;(引用当前目录和jdk安装目录)

 

1.2第一个Java程序的编写

  • 打开记事本 输入以下代码,并保存为Hello.java
      
1 public class Hello{
2        public static void main(String[] args){
3      System.out.println("Hello world");
4      
5       }
6 }

 

  • 按下window+r 输入cmd(命令提示符),切换地址到Hello.java的文件目录
输入    
           
javac Hello.java
​
java Hello

 

  • 可以看到上面显示

                 Hello World

 



注意;

​ java程序源文件的命名后缀必须是.java,通常java源文件名可以是任意的 ,但如果java中定义了public类,则该源文件名必须与public类的类名相同。

​ 一个java可以有多个类定义,但只有一个public类定义。

​ 通常情况下首字母大写。

 

Guess you like

Origin www.cnblogs.com/zq0724/p/11241081.html