Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 339
Finn Frankis Avatar asked Mar 09 '26 21:03

Finn Frankis


2 Answers

If you want to export jar file then you first get maven extension installed in your vscode. In explorer of your vscode, you can find different options as shown in screenshot below. enter image description here

In JAVA PROJECTS you can find option export jar(shown by right arrow). Just click on it and it will automatically create jar file of your project.

like image 159
Mayank Kumar Thakur Avatar answered Mar 11 '26 13:03

Mayank Kumar Thakur


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.

like image 21
Cesar Avatar answered Mar 11 '26 13:03

Cesar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!