Java Learning (i), downloading, configuring environment variables, first demo

Source: Internet
Author: User

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

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.