Abhinav Rana
Abhinav Rana

Reputation: 63

How to Create a Java Project for Visual Studio Code

I have just transitioned into Visual Studio Code from Eclipse for Java. I want to create a simple HelloWorld folder which has src and bin folders. However, I do not know how to create the .classpath, .project, and .settings the same way Eclipse does it. How do I do this?

Upvotes: 6

Views: 13320

Answers (3)

Berzohr
Berzohr

Reputation: 416

First you need install some packages for Visual Studio Code. You can find all in this Microsoft Support page: https://code.visualstudio.com/docs/java/java-tutorial

After you have installing it, you can press CTRL+SHIFT+P and type Java for get all commands.

In your case, for make a new project, follow these tips:

  1. Press keys: CTRL+SHIFT+P to open Command menu
  2. Type: Java: Create Java Project
  3. Select a project type, like No build tools
  4. Select the project location
  5. Type the project name, like: My first program
  6. If appear the alert window, trust the authors of the files in this folder by pressing the button Yes, I trust the authors

Now your project is created. You can see the folder src with the file App.java and the Hello World's code inside.

Now for testing your first program, press the right mouse button on App.java file and select Run Java

menu from visual studio code

Now, if all works, your Hello World's program is printed on your Terminal window. output in terminal window

Upvotes: 0

Ethan Gumabay
Ethan Gumabay

Reputation: 91

Hit Ctrl+Shift+P to show all commands, then type "Java" and select "Java: Create Java Project"

Upvotes: 9

Roberto Gimenez
Roberto Gimenez

Reputation: 304

Visual Studio Code doesn´t have this orientation of creating a project because it´s file oriented. It´s on of the diferences with Visual Studio.

It means that creating a project structure is based on folders and files, and no file references and links the folders and files to a project. If you want to create a project with src and bin folders, you´ve to do it manually.

Upvotes: 1

Related Questions