How to generate executable program . jar in VS Code?

Asked

Viewed 3,107 times

0

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

  • Possible duplicate or related:How to create a file . jar appropriately?

  • The VSCODE is unrelated to the generation of .jar. You’re looking for an automated way, that’s it?

  • 1

    Which plugin you use to compile and run Java code in VS Code?

  • Oops, Marcelo understood I thought there was some way, I know by netbeans

  • Both the netbeans and the eclipse use the ant to automate the creation of jars, but in netbeans, it takes care of configuring build.xml, and in eclipse this does not always occur and sometimes it is necessary to configure manualment.

  • Articuno - More in VS Code would have some possibility to get this executable?

  • LINQ - I don’t use any at the moment I’m wanting to find out, I saw that it has a Manven plugin

Show 2 more comments

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 the jar. The visual code has a built-in terminal.

  • Thanks Bruno... I will perform this test here

0

If you have an updated version of Visual Studio Code you can configure in task.json.

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

    workspace

  • You may notice that I created a Workspace (would be like a project) called java-teste
  • Press the keyboard buttons Ctrl+Shift+p
  • In the search I typed "Configure Task"
  • Click on the "Create tasks.json file from template"
  • Some options will appear, select "Others"

It will generate a standard template, like this:

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

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


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

  • Thanks William. I will perform this test... Sorry the delay in returning

Browser other questions tagged

You are not signed in. Login or sign up in order to post.