JAVA learning (a) ----- JAVA environment to build | jdk installation configuration | run

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/q303705455/article/details/95383290

jdk installation and configuration (jdk8 based) | JAVA environment to build

Download jdk installation package, it is recommended to use 64-bit architecture
under the window:
1.jdk Note path (not Chinese, and special characters)
2. configuration environment variable (computer → Properties → Advanced → Environment Variables) :( option to create a JAVA_HOME's)
1) .JAVA_HOME: value is the home directory of the installed jdk
2) disposed in the path: Example:% JAVA_HOME% \ bin.
under win10 system version: adding at the end; the JAVA_HOME%% \ bin
3. test successful: in cmd command line: the Java -version
javac -version

linux under:

  • Use the rpm package, can be installed directly, no need to configure (rpm -ivh jdk1.8xxxxx.rpm) (ps: the version number available -qa rpm | grep
    the JDK filtered right view and copy)
  • Recommended installation package with tar, because rpm dependency problems:
    1. xshell rz command by the introduction of good jdk tar package
    2. Extract (tar -xvf xxxxxx.tar)
    3. configure the environment variables: general recommendations system level configured (entered vim / etc / profile)
    need to be configured to the user's level of environmental variables (not recommended) (entering vim /.bash_profile)
    after entering 4. Add the following code in the last few lines: export JAVA_HOME = java home directory
    export PATH = P A T H : {PATH}: JAVA_HOME / bin
    5. Save and Exit
    6. The test was successful: the Java -version
    javac -version

Run the program

代码:
public class Test{
public static void main(String[] args){
System.out.println(“hello,world!”);
}
}

the window:
1. EditPlus written in the first program code as stored in the specified path (ps: save the name should be the same class name, for example, save as Test.java)
2. Enter the specified path cmd, enter javac after Test.java compiled successfully enter java Test (ps: pay attention to this point without adding the suffix name, file extension after the javac compiler named .class)
3. display hello, world after the success!

the Linux:
1. In the presence of the test javac and java (java -version; javac -version), enter a new file (Example: vim Test.java) at a specified path
2 in which the preparation of the first program mode entry command code above, save and exit after completion
3. enter javac Test.java, java Test after successful compilation input
display hello, world 4. Upon successful!

Guess you like

Origin blog.csdn.net/q303705455/article/details/95383290