Home > Blockchain >  I'm compiling and running fine my java project inside VS Code, but how can I compile it and run
I'm compiling and running fine my java project inside VS Code, but how can I compile it and run

Time:05-16

I have this organization inside VS Code: https://imgur.com/a/HXWo1VF I just click on the "play" button and the app opens just fine. The command that VS Code use to run it is:

$ cd "/home/allexj/Dropbox/ingegneria_del_software/Link to ing_del_softw/codice/VipagePharma/vipagepharma" ; /usr/bin/env /usr/lib/jvm/java-11-openjdk/bin/java @/tmp/cp_8o2vekaqsyood6mnlra3x7qpf.argfile -m com.vipagepharma/com.vipagepharma.App

The build command is not showed, so I don't know how VS Code build it and I am newbie so I'm kinda poor in package and compiling stuff.

Inside /tmp/cp_8o2vekaqsyood6mnlra3x7qpf.argfile there is:

-cp "/home/allexj/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13.jar:/home/allexj/.m2/repository/org/openjfx/javafx-graphics/13/javafx-graphics-13.jar:/home/allexj/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13.jar:/home/allexj/.m2/repository/org/openjfx/javafx-fxml/13/javafx-fxml-13.jar" --module-path "/home/allexj/Desktop/ing_del_softw/codice/VipagePharma/vipagepharma/target/classes:/home/allexj/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13-linux.jar:/home/allexj/.m2/repository/org/openjfx/javafx-graphics/13/javafx-graphics-13-linux.jar:/home/allexj/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13-linux.jar:/home/allexj/.m2/repository/org/openjfx/javafx-fxml/13/javafx-fxml-13-linux.jar"

How can I build and run the same code in another machine? I don't know how VS Code has built everything, so I don't know how to do it in a portable way. Say you cloned this repo: https://github.com/All3xJ/VipagePharma/tree/main and you have to build&run it. How to do that?

CodePudding user response:

You can convert project to a Maven project or create a jar file using jar cf jar-file input-file(s) and then run jar file using java -jar <jar-file> command

Guide to Creating and Running a Jar File in Java

Creating a JAR File

CodePudding user response:

You can export your build to JAR from the projects view or by running the command Java: Export Jar....

You can refer to the document for more details.

  • Related