3

I am working on a cli java application. And one of my options is to build a jar file. But I don't know how to start this. I can't find a example on the internet.

I know how to build a jar file and to execute it in the command line. I already searched on youtube and internet but I can't find a example on how to do this.

I expected to build a jar file with a java cli application. For example the users enters the option to build the jar file and in the same directory there is a jar file made by classes of the cli application.

J_P
  • 189
  • 1
  • 2
  • 12
  • 1
    Possible duplicate of [How to execute "javac and java commands" from java program?](https://stackoverflow.com/questions/12402547/how-to-execute-javac-and-java-commands-from-java-program) – geco17 Aug 25 '19 at 08:14
  • At least three options: (1) The [`java.util.jar`](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/util/jar/package-summary.html) API; (2) Execute the `jar` tool via the [`ToolProvider`](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/util/spi/ToolProvider.html) SPI (also see the [`jdk.jartool`](https://docs.oracle.com/en/java/javase/12/docs/api/jdk.jartool/module-summary.html) module); (3) Execute the `jar` tool in another process via the [`ProcessBuilder`](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/lang/ProcessBuilder.html) API. – Slaw Aug 25 '19 at 08:28
  • Possible duplicate of [Java creating .jar file](https://stackoverflow.com/questions/4597866/java-creating-jar-file) – Kavitha Karunakaran Aug 25 '19 at 08:41

0 Answers0