Algorithms, 4th Edition -macOS+vscode+IntelliJ environment build

See Hello World in Java (Mac OS X)

You will create and compile Java programs and run bytecode programs from the command line.

Java -version # macOS uses version 1.8 by default

0. Install the Java programming environment

Double-click to install lift-java.pkg and keep the default Settings.

1. Open a project with vscode

Vscode organizes Java programs as projects, with a project for each assignment. A typical project contains Java programs, associated data files, and class-related configurations, such as compiler options, type rules, and textbook libraries.

Then I created a folder called book_Algorithms-4th-Edition. I just put hello Project in it and put all my future assignments in it.

Open the hello folder in vscode

Create a new Java Program in vscode

The hello folder is only opened, not as a Java Project, so see Getting Started with Java in Visual Studio Code

Getting Started with Java in VS Code

Setting up VS Code for Java development

Install the Coding Pack for Java-MacOS, which is mainly the Java environment of the operating system and the plug-in of VScode. You can also Install the Coding Pack separately. You can also install each plug-in separately.

Configure the JDK

The version of the Java environment that vscode plug-ins depend on and the version of the Java environment that the project depends on are two separate programs. Use the Java Runtime Environment configuration wizard

You can also configure the Java runtime environment Using VS Code Settings

Creating a source code file

However, there seems to be a big difference between vscode and IntelliJ, so I prefer to use IntelliJ after consideration, because the.idea and.lift in it seem to be related to IntelliJ, which cannot be used with vscode.

Create a new Java Program

The Java file will then be opened automatically

Compile and execute this Program from IntelliJ

The first step is to compile it into an executable file suitable for the operating system environment

Select the Program file that you want to compile, which is a.java file that contains a Class with the same name as the file that you want to compile, select this file and compile it.

This compilation is quite time-consuming, I don’t know why, it should be quick to print.

Then it’s ready to run

Compile and run Program from the command line

5. Textbook library

summary

The book “Algorithm” was bought many years ago, but I don’t know why, I stopped reading it at the beginning, and then the book was sold. Now I have bought the book and started reading it from the beginning again. I don’t know what the problem is.

changelog

  • July 06, 2021