Search code examples
javavisual-studio-codejar

Is there a command in Visual Studio Code That will convert your java project into an executable jar file?


I am going to participate in a game jam tomorrow, and I am going to make the game with java in visual studio code. The only problem is once I finish the game I don't know how to export it to an executable jar file. I am posting this question to ask if there is a command in visual studio code that will allow me to export it.


Solution

  • I assume your project is no build tools, so here is my solution about export ing projects to jars. Turn to folder src:

    1. Compile the .java file with main method, which generates the .class file:

       javac App.java
      
    2. Generate .jar:

       jar cvfe App.jar App .\
      
    3. Run the jar:

       java -jar App.jar
      

    enter image description here

    Detailed command information, please view The Jar Command.