[Java] How does Eclipse create a java project and run it

After the previous installation of Eclipse and JDK and the configuration of JDK environment variables, start basic use

1. Create a java project and run it

1. First open Eclipse IDE
insert image description here
2. Create a project
Click File—>New—>Project in the upper left corner, so that you can create a new Java project. In other words, in Eclipse, our Java projects will be stored in the workspace namespace, and multiple Project items can be stored in one namespace.
insert image description here
3. After selecting Project, you will enter the following interface, select Java—>Java Project, and then click Next
insert image description here
4. Name the project here, do not use Chinese naming. In the following Module, please do not check it for the time being Create module-info.java file, because we will not be involved in this modular mechanism for the time being.
insert image description here
5. Click Next to enter here
insert image description here
6. Click Finish, and then choose: Open Perspective or No can be used
insert image description here
7. In this way, a Java project is created in Eclipse, and then the Java class needs to be created in the src directory
insert image description here
8. Create Java class: right-click the src directory, click New—>Class
insert image description here
9, set the class name and modifier here, and then click the default Finish
insert image description here
10, write a java program
insert image description here
11, run the project: right click, select Run As—>Java Application
insert image description here
or Click the small green triangle
insert image description here
12. See the running results in the Console window
insert image description here
Remarks: If you do not see the Console window in the main interface, you can select the menu Window—>Show View—>Console to display it.

Two, Eclipse code formatting

1. Open the program and select the code to be formatted.
insert image description here
2. Click the Source menu on the menu bar.
insert image description here
3. Click the Format option on the drop-down menu.
insert image description here
4. The code has been formatted
insert image description here
Source code:

package TestDemo;

import java.util.Scanner;

public class Cipher {
    
    
	private static int[] enc_key = {
    
     6, 3, 0, 4, 5, 1, 2 }; // 加密密钥
	private static int[] dec_key = {
    
     2, 5, 6, 1, 3, 4, 0 }; // 解密密钥

	public static void main(String[] args) {
    
    
		char[][] m = new char[2][7];
		char[][] c = new char[2][7];
		char[][] dec_m = new char[2][7];
		System.out.println("请输入两行7个英文字符的明文:");
		try (Scanner scanner = new Scanner(System.in)) {
    
    
			m[0] = scanner.nextLine().toCharArray();
			m[1] = scanner.nextLine().toCharArray();
			for (int i = 0; i < 7; i++) {
    
    
				c[0][enc_key[i]] = m[0][i];
				c[1][enc_key[i]] = m[1][i];
			}
			for (int i = 0; i < 7; i++) {
    
    
				dec_m[0][dec_key[i]] = c[0][i];
				dec_m[1][dec_key[i]] = c[1][i];
			}
			System.out.println("您输入的原始明文为:");
			System.out.println(m[0]);
			System.out.println(m[1]);
			System.out.println("加密结果为:");
			System.out.println(c[0]);
			System.out.println(c[1]);
			System.out.println("解密结果为:");
			System.out.println(dec_m[0]);
			System.out.println(dec_m[1]);
		} catch (Exception e) {
    
    
			System.err.println(e);
		}
	}
}

3. Delete items

1. If you don’t want an item, you can delete it directly. Select the item—>right click—>Delete.
insert image description here
2. If you want to delete this item completely from the computer, you can check the check box below. Otherwise, it is just removed from the Eclipse directory and will not be completely deleted.
insert image description here

Guess you like

Origin blog.csdn.net/Cappuccino_jay/article/details/130383980