Pustaka Taratsa

Baca teks (EPUB): JAVA: Convert .java ke .jar

1 bagian

Teks ini diambil langsung dari berkas EPUB; tata letak dan gambar tidak disertakan. Untuk tampilan lengkap, silakan merujuk pada dokumen asli.

Daftar isi
  1. JAVA: Convert .java ke .jar
  2. Referensi
  3. Pranala Menarik

JAVA: Convert .java ke .jar

Sumber: https://onnocenter.or.id/wiki/index.php/JAVA:_Convert_.java_ke_.jar

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