Although I introduced object-oriented programming using Java in my undergraduate class, I will re-introduce it after reviewing it because "I forgot it a long time ago ...".
I used Java in my undergraduate classes about two years ago, but since I'm using it for the first time after renewing my PC, I have to build a development environment. Eclipse is famous as an integrated development environment and was used in lectures. However, I didn't want to install it newly because of Java, which is used infrequently, so I built the environment using VS Code.
The environment was constructed with reference to here. The following is an outline of the environment construction written in the link.
If you have not installed the JDK, you need to download it from the following.
VSCode for Java seems to be available in Java SE 11 and above, so you can download the latest JDK from the link above.
Be sure to make a note of the path when you install it, as you will set the path in the next step.
This time, Java can be used only with VS Code, so it is enough to set `` `java.home``` of VS Code. The setting procedure is as follows:
`Ctrl +,`
)Example of path to set
{
...,
"java.home": C:\\Program Files\\Java\\jdk-13.0.2,
}
Next, install multiple VS Code extensions that are famous for Java development at once. The procedure is as follows:
You should now see the "Java Extension Pack" at the top. Press the Install button and wait for a while to complete. Now you have a Java environment using VS Code!
A project is a collection of source files that make up the program to be developed and settings for compiling and executing them. Let's create a project right away.
Open the command palette with Ctrl + Shift + P` `` or` `F1
and select
Create Java Project` ``
Select ``` No Build Tools` `` as the project type
Select a folder
Enter the name of the project (here `` `HelloWorld```)
You have now created a project!
When you create a project, some files will be created automatically as shown in the image below.
src/App.Looking at java, Hello by default, World!There is a program that outputs.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/486404/2928068c-7593-1255-67ee-a4b2c96486dd.png)
It says ``` Run | Debug``` above main.
To run this program, just click on this `` `Run```.
#### **`Execution result`**
```java
Hello, World!
You have now created and run your project!
In a future article, I will introduce object-oriented programming while implementing rock-paper-scissors.
Recommended Posts