First, download Java JDK in http://www.oracle.com
Install to a custom location.
Second, configure environment variables: In My Computer → advanced system settings → environment variables
① find path to add a path (the path to the location of the JDK storage bin, for example, I placed under D:\J2EE\JDK1.8.0\bin), two paths to be separated by a semicolon
② in order to prevent path changes, you can add a variable, variable name custom, the value of the variable is the JDK storage path.
Then add a path under Path to%java_home%\bin.
Save after Run (win+r) cmd type java-version to see the version of the JDK (if not configured, you should point the path to the bin file to see)
Third, complete the first demo, first edit in a text document
Create a text document with a suffix of. Java, edit the document, fill in the content as
1 Public class first{ 2 public static void main (String []args) { 3 System.out.println ("Firstjava" 4 System.out.print ("firstjava\n" ); 5 System.out.println ("Firstja\tva" ); 6 7 }
View Code
With public, the method name must be the same as the file name, and there can be only one publicly available method with the same file name, and the rest of the methods need not be added.
Iv. Run (win+r): cmd, first to the directory where the file is located type ①d: (open D-Disk) ②CD Javastudy (to Javastudy folder) ③javac First.java (Generate. class file)
④java first (execution method)
V. Generate CLASSPATH (Configuration temp): ①set classpath=d:\javastudy (set classpath path)
②java first (execution method, can be executed under any path)
Viii. generate Classpath (permanent): In My Computer → advanced system settings → environment variables
Add a classpath variable, path D:\JavaStudy OK and reopen cmd
Java Learning (i), downloading, configuring environment variables, first demo