Java Learning (1), download, configure environment variables, first demo, environment variable demo

Source: Internet
Author: User

Java Learning (1), download, configure environment variables, first demo, environment variable demo

1. download java JDK in http://www.oracle.com

 

Install it to a custom location.

2. Configure environment variables: on my computer → advanced system settings → Environment Variables

① Add a new Path to the Path (this Path is the bin where JDK is stored, for example, I placed it under D: \ J2EE \ JDK1.8.0 \ bin). separate the two paths with extra points.

② To prevent path changes, you can add a variable, which is customized by the variable name. The variable value is the JDK storage path.

Add a new Path named % JAVA_HOME % \ bin under Path.

Save and run (win + R) cmd. Type java-version to view the jdk version. (if not configured, the path should be directed to the binfile)

3. Complete the first demo and edit it in the text document.

Create a text document with the suffix. java. Edit the document and enter the content

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

After public is added, the method name must be the same as the file name. Only one public method (public) with the same file name can be used in a file, and no public method is required for other methods.

4. Run (win + R): cmd. First, enter ① d: (Open d disk) ② cd JavaStudy (under JavaStudy folder) ③ javac First. java (generate. class file)

④ Java First (execution method)

5. Generate classpath (temporary configuration): ① set classpath = d: \ JavaStudy (set the classpath path)

② Java First (execution method, which can be executed in any path)

8. Generate classpath (permanent): On my computer → advanced system settings → Environment Variables

Add a classpath variable, specify the path D: \ JavaStudy, and re-open cmd.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.