I started learning Java, before that I had experience in Python. In Python, I could write the code save to a file with the extension .py and just run it. In Java, this does not work out; you just need to use cmd or a terminal in Linux to run files with code. But launching just a file is not enough, for example, I want to write some albeit even a console application and transfer it to someone for the sake of interest, but it will be stupid to ask a person to launch it through the console. How can I pack files such as .exe?

  • use for example intellij idea - Shakirov Ramil
  • one
    There are no exe files in java, jar is used instead, in order to build a jar you can use any IDE. Of course, you can also collect jar through the console, but it's hardly necessary to use it, here is an example habrahabr.ru/post/125210 - diofloyk

1 answer 1

Generally, if there is such a desire to pack a java program in an exe, you need to think about whether you have chosen the language?

But if you answer your question, you can:

  1. Build exe with:

  2. Pack the program in jar (by implementing the console interrupt logic, for example, via the Scanner, so that the program does not close after execution)

  3. Pack the program in jar and write a .bat file with the following code: java -jar youApp.jar pause

  • Excelsior generally does a powerful thing - the Java compiler. ) - Nick Volynkin