How to make my program executable?

Asked

Viewed 739 times

-2

the graphical interface is already built and it runs if I compile. how to create the executable to run on any machine?

  • 1

    Are you using any IDE?

  • 2

    Which platform? A file jar should work on any platform that supports Java, but an "executable" will only work on a specific platform (e.g., Windows, Linux, Mac).

  • i tried to open the . jar that was inside the folder Netbeansprojects Project dist , but it did not work

  • in netbeans is the run->clean and build project menu (Shift + F11) it generates the . jar and gives the path to the folder where generated

  • The generated jar gave problem in the manifest?

2 answers

1

To distribute/run a Java program, basically you must generate . jar (which depends on how you did the project, if you used Maven for example would run the package phase) and also if you are using an IDE. With the . jar ready, you should create batch files to run in each environment. In windows it will be a . bat and in linux and mac .sh. In these files you can (if necessary) set properties like JAVA_HOME, JAVA_OPTS, classpath, etc. In one of the projects I work there are examples: https://github.com/demoiselle/nimble/tree/master/impl/core/src/main/scripts

0


It depends on the IDE you’re using. On the command line would look something like this:

java NomeDoPrograma

Note that the program name does not end with . class If the program has several packages then you have to do so:

java caminho/para/o/pacote/com/a/classe/principal/NomeDoPrograma

If you are in the Netbeans IDE just click on the Boot that has a hammer and a broom on top, and it will create a file. jar in which you can find in the path of your program where it is stored. o . jar should stay +/- this way

/NetBeansProjects/NomeDoProjeto/dist 

the jar must meet there.

Browser other questions tagged

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