I am a beginner in java, and hence do not know maven or boot Spring. I have tried Eclipse and IntelliJ, and wanted to try Visual Studio Code. I can make an Eclipse Project in VS Code but I cannot find any option there. I have installed the Java Extension for Visual Studio Code. Any Help would be appreciated. I am using the latest Visual Studio Code March 2020. Thanks in advance!
6 Answers
Image showing where to Right Click: create a Java Package in VS Code
Inside the Java Projects tab, right click on the project. You can then choose to create a new Java Class or Package.
3 Comments
Extension Pack for JavaI had the same situation as you, I figured creating packages on my own in VS code, Just follow these steps: Open up your VS code.
Step 1: Click on "Explorer" , should be at top-left corner.

Step 2: Click on "New Folder"
Step 3: Enter the name of your package here.
Step 4: Drag and drop the your classes in that package.
You are all set now! Good luck!
Comments
I would recommend checking out Java Env Setup for VS Code.
and secondly:
A package is a path of subdirectories. Say your java sources are in (subdirectory of) a > directory src. All sources immediately under src have the "default" package = no package > declaration.
In src/com/java/learn (4 nested directories) the package com.java.learn; is expected for > java sources.
In your case create a path of 3 directories: com, java, and learn the latter containing > your java source.
recycled from here: How to Start a Java Project with package declaration on Visual Studio Code?
Comments
Even I was in the same situation so I researched and got some results. Make sure you have JDK and JVM in your machine
You need to install Extension pack for java (from Microsoft) which is available by searching in extensions in Visual Studio
Make sure you install all the packages related to that extension such Maven for Java, Debugger for java, Project Manager for Java and Test runner for java all these are from Microsoft. After installing these you can run your java files.
Comments
To create a new package in Visual Studio Code for a Maven project, follow these steps:
Right-click on the location where you want to create the package (e.g., inside the src/test/java folder). Select New Folder. Name the folder with your desired package name, appending \package at the end. For example, if you want to create a package named package23, name the folder package23\package.
This will correctly set up the package structure in your Maven project.


