Hang on the fourth edition of IntelliJ IDEA algorithm built environment

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_43152052/article/details/100155374

1, path path Add:

Environment variable opening method:我的电脑—>(右键)属性—>高级系统设置—>环境变量

1.1, jdk the path path to add, verify jdk path is added successfully enter cmd in need java on the line, back a long list of characters appearing on the success it represents an input.

Here Insert Picture Description


Path 2.2, algs_4.jar added packet,To be the new environment variable CLASSPATHThen algs4_jar the absolute path added to it just fine.
Here Insert Picture Description

Note: The download package algs4.jar

Here Insert Picture Description

2, idea entry and add the .jar and jdk

2.1, idea to create a new project: file-> new-> project (the rest is their own definition of the project name and the absolute path of the project is located)

2.2, then add the source code is the same as a similar vs, attentionJava class name must be consistent with the source file nameOtherwise, the compiler does not pass. We srcadd a Java class in which:
Here Insert Picture Description

2.3, jar package is introduced into the jdk added: file-> Project Structure
Here Insert Picture Description

2.4, this should be the most pit the point where the algorithm 4th edition of algorithm testing is 通过文件数据to test, for example tinyW.txt < tinyT.txt.
In the run-> edit configurations to set an invalid command-line arguments, and does not automatically output data (do not know the specific reasons for the relative and absolute paths are used, but still can not automatically output data):
Here Insert Picture Description

Switch to manually compile .java in the Terminal will be able to automatically output the data (no wonder the book has been manually enter the command-line arguments, so we can only manually compile the .java ??)
Here Insert Picture Description
Note: cd + absolute path to the directory, javac command is used to compile .java, java command to run the .java (this step is not required suffix, with the class name on the line). Here I use the java command directly compile and run the .java, save a little.

Guess you like

Origin blog.csdn.net/qq_43152052/article/details/100155374