First, install the JDK
Download a JDK, install it, and remember the path to the installation
Second, the Environment configuration
This computer--properties--Advanced system settings--environment variables
New system Variable: variable java_home value: C:\Program files\java\jdk1.8.0_11
If this is not successful, you can add the path variable to the user variable with the value: C:\Program files\java\jdk1.8.0_11
Third, build a Java file with a text document
Write a HelloWorld
1. Create a new text document, named HelloWorld, and write the following code in the document:
1 public class helloworld{ 2 public static void Main (string[] args) { 3 System.out.println ("Hello World !"); 4 }5}
2. Change the suffix name of the text document to. java
3.windows+r input cmd
Input g:g refers to the file stored in the G disk
Enter Javac Helloworld.java to compile the code you write
Enter Java Hellowworld run
Iv. Building a Java file with eclipse
Build a Java project first, then create a new package in SRC, and then create a new class.
1. Name of the package: COM. company name. XXX
New Project: File--new--java Project
New package: SRC Right-click--new--package
2. Class naming: The class name must be consistent with the file name
New class: Package right button--new--class
3. Code writing:
Write the following code:
1 package com.jerehedu.ch01; can automatically generate 2 3 public class HelloWorld { //can automatically generate 4 public static void Main (string[] args) {5 System.out.println (" Hello world! "); 6 }7}
Here are some things to keep in mind:
alt+/Quick Tips
The main method is the execution entry for the Java program;
each Java file can have at most one main method;
four elements of main: public static void parameter, Integral!
println: After you have printed the contents of "", wrap the text automatically;
\ n line break also use
\ t tab, tab to return the cursor to the next tab stop. One tab stop eight characters
bin holds compiled executable bytecode file
SRC holds Java source file
Comments: Comments have single-line comments, multiline comments, and Document Comments
single-line comment: //
Multiline comment: /* explanation of code
Documentation Comments:/** compared to multiple lines of comments, When commenting on a method with a document comment, the mouse points to the method name, and you can see the canonical content of the
code for the comment:
class name using the public modifier
Write one line of code
{} format, note one by one for
Note indent
First knowledge of Java