I'm trying to create a maven project - so that I can compile Java files in the root folder and output the class files in another folder.
I've already downloaded mvn.
I'm trying to integrate with VS Code. My goal is to edit the java files in VS Code and on saving the compiler saves the .class file in the appropriate output folder.
That's all - no war or jar files.
Any help?
This question is related to
java
maven
visual-studio-code
project
An alternative way is to install the Maven for Java
plugin and create a maven project within Visual Studio. The steps are described in the official documentation:
This is not a particularly good answer as it explains how to run your java code n VS Code and not necessarily a Maven
project, but it worked for me because I could not get around to doing the manual configuration myself. I decided to use this method instead since it is easier and faster.
Install VSCode (and for windows, set your environment variables), then install vscode:extension/vscjava.vscode-java-pack
as detailed above, and then install the code runner extension pack, which basically sets up the whole process (in the background) as explained in the accepted answer above and then provides a play button to run your java code when you're ready.
This was all explained in this video.
Again, this is not the best solution, but if you want to cut to the chase, you may find this answer useful.
I surprise no one had mentioned this possible easy approach in visual studio code.
Install VS Code and Apache maven ( just as mentioned by @Steve Chambers)
After installing this extension vscode:extension/vscjava.vscode-java-pack
In the java overview page , there is a an option which reads 'Create Maven Project' which further takes to a simple wizard to generate maven project.
Its pretty quick which is intutitive enough, even newbies can very well start with a Maven project.
Source: Stackoverflow.com