2

Hi I want to create a jar file...

I'm using Windows

QUESTION 1 (or problem)

The classes are stored:

"d:\Información\Developer\a  a JAVA sources\Folder classes"

I want to create the myRT.jar file in:

"D:\Información\Dev\a  a JAVA sources\myRT.jar"

The MANIFEST.MF file: already is included:

for this reason I will trying with M (Upper case M Letter) and without m (Lower case letter)

My tests was:

"C:\Program Files\Java\jdk1.8.0_91\bin\jar.exe" 
  cvfM "D:\Información\Dev\a  a JAVA sources\myRT.jar" 
  -C "d:\Información\Developer\a  a JAVA sources\Folder classes\"

Without "\" ending the -C option

"C:\Program Files\Java\jdk1.8.0_91\bin\jar.exe" 
  cvfM "D:\Información\Dev\a  a JAVA sources\myRT.jar"
  -C "d:\Información\Developer\a  a JAVA sources\Folder classes"

Without Upper Case M Option

"C:\Program Files\Java\jdk1.8.0_91\bin\jar.exe" 
  cvf "D:\Información\Dev\a  a JAVA sources\myRT.jar"
  -C "d:\Información\Developer\a  a JAVA sources\Folder classes"

Previously this work fine for me:

"C:\Program Files\Java\jdk\bin\jar.exe" 
  cvfm "D:\Developer\java\dist\some.jar" 
  "d:\Developer\java\MANIFEST.MF"
  -C D:\Developer\java\classes bz\pckg

QUESTION 2

How you are rt.jar supplied compressed or with "-0 store only; use no ZIP compression" option?

QUESTION 3

Is there advantage for jar file? speed: no compression (with -0 option) space: with compression

QUESTION 4

What arguments are used by Netbeans (by default) to compress jar files?

PD

I was reading the help

https://docs.oracle.com/javase/tutorial/deployment/jar/build.html

How to create jar file with package structure?

How to run a JAR file

Run jar file in command prompt

Community
  • 1
  • 1
QA_Col
  • 1,095
  • 9
  • 23
  • Unless you have a very good reason, don’t use `-0`. Just use the default compression. (Disk access is far, far slower than decompression.) Are you aware that all of your commands fail to specify any files to place in the .jar file, except for the command you said worked for you? – VGR May 27 '16 at 20:39
  • Hi, my new changes are: the space in the path and special characters in the name like `ó ` character, and I omited the Manifest file. For `-0 ` option isn't clear for me your comment: Is recommended or not recommended to used? (what's the reason)... – QA_Col May 28 '16 at 01:44
  • You ignored everything in my first comment. I repeat: Your commands are not specifying any files to include in the .jar file. As for `-0`, *do not* use it. Java will load an uncompressed .jar file much slower than it will load a normal, compressed .jar file. `-0` is *not recommended.* – VGR May 28 '16 at 11:19
  • Thank you.... I'm estableshing that files are stored on the folder using the `-C` option: *folder containing files to be compressed* `-C "d:\Información\Developer\a a JAVA sources\Folder classes" `. – QA_Col May 28 '16 at 15:25

1 Answers1

0

jar.exe works with:

"C:\Program Files\Java\jdk1.8.0_91\bin\jar.exe" 
    cvfM "D:\Información\Dev\a  a JAVA sources\myRT.jar" 
    -C "d:\Información\Developer\a  a JAVA sources\Folder classes"
    .

or

"C:\Program Files\Java\jdk1.8.0_91\bin\jar.exe" cvfM "D:\Información\Dev\a  a JAVA sources\myRT.jar" -C "d:\Información\Developer\a  a JAVA sources\Folder classes" .

Note the . ending the order.

I'm not sure, but checking the rt.jar's header I saw this:

Header Uncompressed jar file:

50 4B 03 04 0A 00 00 08

Header Compressed jar file:

50 4B 03 04 14 00 08 08

Then rt.jar was submit like uncompressed file, and reviewing my default builded Netbeans project, I have the same header for uncompressed jar file.

For your Q3: I think when 0 option is not selected, that the program (Java) needs to load the compressed file and internally needs to decompress, then I have Memory space (Compressed File + Uncompressed File), and needs to work to uncompress the content. That means is slower and heavier.

joseluisbz
  • 2,590
  • 1
  • 30
  • 48