Java basic tutorial 1: Environment configuration and HelloWorld. java,
This article describes JDK environment configuration, Sublime Text3 configuration, and a HelloWorld. Java program. The running environment is Windows 10 and JDK is used.
1. JDK download and environment configuration 1.1 JDK download 1. Official Website: http://www.oracle.com/technetwork/java/javase/downloads/index.html2. Select the appropriate JDK version as needed, here choose the current mainstream 1.8 version
Java SE 8u151/8u152, Click JDK download 3. Install and download JDK1.2 to configure system environment variables
1. First, go to the Java JDK installation directory. The default value is C: \ Program Files \ Java. Find the corresponding JDK version, such as jdk1.8.0 _ 144.
2. Right-click "this computer" and select "properties", select "Advanced System settings" on the left, select the "advanced" tab on the top, and click "environment variables" in the lower right corner.
3. Click create in the following system variables column. Enter JAVA_HOME in the variable name field, and enter the JDK path found above in the variable value field, such as C: \ Program Files \ Java \ jdk1.8.0 _ 144.
4. click "new" in the system variable, enter "CLASSPATH" in the variable name, and enter ".." in the variable value :.; % JAVA_HOME % \ lib; % JAVA_HOME % \ lib \ tools. jar (do not forget the semicolon between the front and middle)
5. Find the Path in the system variable, click Edit, and click New. Add % JAVA_HOME % \ bin and % JAVA_HOME % \ jre \ bin in sequence.
In this way, we have configured the JDK environment variables. We can run java and javac in CMD to verify whether the configuration is successful.
2. Sublime Text 3 Configuration
IDE here we use Sublime Text 3, which is a cross-platform code/Text editor with a simple and elegant interface. We can use debugging tools that are useful when learning java. (IntelliJ IDEA or Eclipse is recommended for Java development)
2.1 Download Sublime Text 3
1.: http://www.sublimetext.com/3
2. Sublime Text 3 registration
Run Sublime Text3, select Help> Enter license, and Enter the registration code to activate it.
—– BEGIN LICENSE —–Michael BarnesSingle User LicenseEA7E-8213858A353C41 872A0D5C DF9B2950 AFF6F667C458EA6D 8EA3C286 98D1D650 131A97ABAA919AEC EF20E143 B361B1E7 4C8B7F04B085E65E 2F5F5360 8489D422 FB8FC1AA93F6323C FD7F7544 3F39C318 D95E6480FCCC7561 8A4A1741 68FA4223 ADCEDE07200C25BE DBBC4855 C4CFB774 C5EC138C0FEC1CEF D9DCECEC D3A5DAD1 01316C36—— END LICENSE ——
—– BEGIN LICENSE —–Free Communities Consultoria em Informática LtdaSingle User LicenseEA7E-801302C154C122 4EFA4415 F1AAEBCC 315F3A7D2580735A 7955AA57 850ABD88 72A1DDD88D2CE060 CF980C29 890D74F2 53131895281E324E 98EA1FEF 7FF69A12 17CA7784490862AF 833E133D FD22141D D8C89B944C10A4D2 24693D70 AE37C18F 72EF0BE51ED60704 651BC71F 16CA1B77 496A0B19463EDFF9 6BEB1861 CA5BAD96 89D0118E—— END LICENSE ——
—– BEGIN LICENSE —–Nicolas HennionSingle User LicenseEA7E-8660758A01AA83 1D668D24 4484AEBC 3B04512C827B0DE5 69E9B07A A39ACCC0 F95F5410729D5639 4C37CECB B2522FB3 8D37FDC172899363 BBA441AC A5F47F08 6CD3B3FECEFB3783 B2E1BA96 71AAF7B4 AFB61B1D0CC513E7 52FF2333 9F726D2C CDE53B4A810C0D4F E1F419A3 CDA0832B 8440565A35BF00F6 4CA9F869 ED10E245 469C233E—— END LICENSE ——
2.1 Sublime Text 3 Configuration
1. Run Sublime Text3, select Preferences> Browse Packages, and open the Packages directory.
2. Enter the User directory
3. Create the file JavaC. sublime-build, enter the following code and save it.
{"Cmd": ["javac", "-encoding", "UTF-8", "-d ",". "," $ file "]," file_regex ":" ^ (... *?) :( [0-9] *):? ([0-9] *) "," selector ":" source. java "," encoding ":" GBK ", // After the preceding command is executed, the following command must be executed by pressing Ctrl + Shift + B to run" variants ": [{"name": "Run", "shell": true, "cmd": ["start", "cmd", "/c ", "java $ {file_base_name} & echo. & pause "], // c is to close the cmd window after the command is executed, // k is to close the cmd window after the command is executed. // Echo. enter a press ENTER // pause command to press any key in the cmd window to close "working_dir": "$ {file_path}", "encoding": "GBK"}]}.3. The first HelloWorld. java
1. Create a HelloWorld. java file and enter the following code:
public class HelloWorld{ public static void main(String[] args) { System.out.println("Hello World!"); }}
This Code defines a HelloWorld class and outputs "Hello World!" on the screen !".
2. Use Sublime Text3 to open the file HelloWorld. java, select the menu Tools> Build System, and select the second javaC.
3. Press Ctrl + Shift + B and select the first JavaC for compilation. The HelloWorld. class file with the same name will be generated in the current path.
4. Press Ctrl + Shift + B and select the second JavaC-Run to Run (or press Ctrl + B)
The running result is output in the pop-up CMD: