Getting Started (c) --- environment to build

Front understanding of the relationship between the JVM, JRE, JDK three, so as to develop our program to this JDK installation.

Official website to download installation package corresponding to the machine:

https://www.oracle.com/java/technologies/javase-downloads.html

 

 

Configuration environment variable:

1. After installation is complete, right-click "My Computer", click "Properties", select "Advanced System Settings";

2. Select the "Advanced" tab, click on the "Environment Variables";

Then the screen will appear as shown below:

Set three properties in the "System Variables", JAVA_HOME, PATH, CLASSPATH (capitalization does not matter), If there is already then click the "Edit" does not exist, click "New."

Variable is set to the following parameters:

  • Variable name: JAVA_HOME
  • Variable value: C: \ Program Files (x86) \ the Java \ jdk1.8.0_91         // to be configured according to their actual installation path
  • Variable name: the CLASSPATH
  • Variable values: ;.% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar;          // in front of a recall. ""
  • Variable name: Path

  • Variable value: % JAVA_HOME% \ bin;% JAVA_HOME   % \ jre \ bin; // win10 system, we need to% JAVA_HOME% \ bin;% JAVA_HOME % \ jre \ bin; adding separately

 
 

JDK is installed successfully test

Open cmd, enter javac / java, a series of command prompt appears, indicating that the configuration succeeded:

 

 

 
 
Description:
1. Set Environment Variables
    Path system variable Path tells the operating system executable files (* .exe, *. Java, etc.) where the path, so that after the configuration tool can be used in any position
    Regardless of the source file in the classpath where after javac generated class files are stored in a single directory configuration under
    JAVA_HOME purpose is to make writing easier path (relative path wording)
    The latter two are managing files
2. Create a problem generated when the source file
    Note that setting up your computer problems
    Is there a hidden extension case
3. The generated source files, and file name are inconsistent bytecode
    Test.java
    Demo.class
Test.java
#Class public front modifier, control class name, class name and the file name is determined
public class Demo{
    public static void main(String[] args){
        System.out.println("hello world");
    }
}
Results of the:
D:\JavaTest\4>javac Test.java
Test.java:1: Error: Demo class is public, should be declared in a file named Demo.java
public class Demo{
       ^
An error
 
>>>> to solve the error: Maintain class names and file names can be consistent

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/wenm1128/p/12502666.html