How to generate .jar executable program in VS Code? [duplicate]

0

Oops, I ran an application in java, now I need to get the .jar executable. How do I get .jar in VS Code?

    
asked by anonymous 01.12.2017 / 14:08

2 answers

1

Hello, you can use the command:

jar cf jar-file input-file(s)

Where input-file (s) are the classes you want in jar. The visual code has a built-in terminal.

    
01.12.2017 / 17:23
0

If you have an updated version of Visual Studio Code you can set it to task.json .

  • First you need to create a "project folder", click the Add workspace button, as in the image:

  • YoumaynoticethatIcreatedaworkspace(itwouldbelikeaproject)calledjava-teste
  • PressthekeyboardbuttonsCtrl+Shift+p
  • Inthesearchbox,type"Configure Task"
  • Click the "Create tasks.json file from template" menu
  • Some options will appear, select "Others"

It will generate a default template like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo Hello"
        }
    ]
}

You can customize and add javac to create .class and then jar cf <nome do jar> to create .jar

Note that .jar is not an executable, but rather a package, as if it were an installer or something, if what you want is just run your script you can install an extension, follow one that is made for this :

01.12.2017 / 22:00