JAVA: Convert .java ke .jar

From OnnoWiki
Revision as of 09:55, 19 August 2023 by Onnowpurbo (talk | contribs) (Created page with "Sumber: https://stackoverflow.com/questions/9941296/how-do-i-make-a-jar-from-a-java-file Simply with command line: javac MyApp.java jar -cf myJar.jar MyApp.class Sure IDE...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sumber: https://stackoverflow.com/questions/9941296/how-do-i-make-a-jar-from-a-java-file

Simply with command line:

javac MyApp.java
jar -cf myJar.jar MyApp.class

Sure IDEs avoid using command line terminal

Ok this is the solution I would have liked to find, instead here I write it:

First create the directory structure corresponding to the package defined for the .java file, if it is my.super.application create the directory my and inside it super and inside it the .java file App.java

then from command line:

javac -cp /path/to/lib1.jar:/path/to/lib2.jar path/to/my/super/App.java

Notice the above will include multiple libraries, if under windows use "," to separate multiple files otherwise under GNU/Linux use ":" To create a jar file

jar -cvfe App.jar App my/app/

the above will create the application with its corresponding Manifest indicating the App as the main class.





Referensi

Pranala Menarik