0

I have 2 java files (main file and a secondary file). I managed to use IntelliJ to build and create a Jar file that works properly.

I want to generate the jar file using commands in the console. I tryed: "javac first.java second.java jar cvf final.jar first.class second.class" It did generate the jar file but the file does not work (the app wouldn't open). furthermore, the "javac" command generate more then 2 class files, inside the first.java code I have another "public class" so after the "javac" command I got: first.class, first$another.class, second.class. Tried "jar cvf final.jar first.class first$another.class second.class", but it didn't help.

My final purpose is to use those commands to generate the jar file inside a jenkins job.

Will appreciate any help with the commands or a reference for a tool in jenkins to help with that issue.

  • 4
    Possible duplicate of [Create jar file from command line](https://stackoverflow.com/questions/11243442/create-jar-file-from-command-line) – jreznot Feb 09 '19 at 11:35

1 Answers1

0

Using Jenkins and all should allow you to use some Maven and POM descriptors. https://www.baeldung.com/executable-jar-with-maven.

CharlieNoodles
  • 316
  • 2
  • 9