Search code examples
javajarvisual-studio-codeexport

Exporting jar file in VS Code


I recently switched over to VS Code from Eclipse as my primary Java editor. I need to frequently export my code into a jar file which includes all libraries and dependencies for running on a Raspberry Pi. However, I currently see no obvious menus or tabs to accomplish this purpose.

Are there any extensions or built-in features which will behave in a manner similar to Eclipse's "Export" window? Would I be able to easily write a script to export for me?


Solution

  • If your project has Maven, you can simply call mvn package or mvn clean install from VS Code's embedded command line. Reference for Maven: https://cwiki.apache.org/confluence/display/MAVEN/Tutorial%3A+Build+a+JAR+file+with+Maven+in+5+minutes

    For spring users in Windows type: .\mvnw package

    EDIT: If you get 'mvn' is not recognized as an internal or external command, operable program or batch file., you need to: download and install mvn. Install is just setting the PATH env.