Link to home
Start Free TrialLog in
Avatar of patelajk
patelajk

asked on

Trying to use jar. Getting 'no such file or directory' error

I'm trying to jar some classes in a directory using the command:-

jar cvfmM Sketcher.jar Sketcher.mf -C *.class

My manifest file is as follows:-

Manifest-Version: 1.0
Main-Class: Sketcher
Created-By: Squills

When I try to jar the classes I get the error 'Constants.class\scaleSlider2.class : no such file or directory'

Any help would be most appreciated

Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Should probably be

jar cvfm Sketcher.jar Sketcher.mf  *.class
Avatar of avinthm
avinthm

Hi patelajk,

Its not able to find the class files.
after -C, you need to specify the directory name, where the .class files are present.

Cheers!
(assuming class files are in current directory)
I *think* you may need the "-" with Windows:

    jar -cvfm Sketcher.jar Sketcher.mf  *.class

Tim
No ;-)
hehhe...ok...  sorry ;-)  ignore me ;-)
Avatar of patelajk

ASKER

My class files are in the current directory.

I tried:-

jar cvfm Sketcher.jar Sketcher.mf  *.class    (ie without the M flag)

This produced :-

java.io.IOException: invalid header field
        at java.util.jar.Attributes.read(Attributes.java:387)
        at java.util.jar.Manifest.read(Manifest.java:167)
        at java.util.jar.Manifest.<init>(Manifest.java:52)
        at sun.tools.jar.Main.run(Main.java:124)
        at sun.tools.jar.Main.main(Main.java:904)

The same happened with 'jar -cvfm Sketcher.jar Sketcher.mf  *.class'

I can get 'jar cvfmM Sketcher.jar Sketcher.mf  *.class' to produce a jar file now without errors but when I try to run the jar file it is corrupt or invalid.

I've saved my manifest file in Unicode format and left a blank line at the end of it.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's the ticket!

Thanks CEHJ.
:-)