Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

The manifest file won't work!!!

stiffmaestrostiffmaestro Member Posts: 16
i know this is kinda dumb of me but i've searched the net about this and nothing helped.
This is my directory structure:
D:javac2j_2_1
|
+----classes
| |
| +----my classes are here
| |
| +----C2JMain.class (this is my main class)
| |
| +----(other classes)
|
+----images
| |
| +----my images are here
|
+----lib
| |
| +----my jar files are here (none so far)
|
+----src
|
+----my classes are here

i want to create a jar file D:javac2j_2_1c2j.jar

so my manifest.mf is :
Manifest-Version: 1.0
Created-By: stiffmaestro
Main-Class: classes.C2JMain
Class-Path: classes

and at the D:javac2j_2_1 directory I invoke the jar command
jar cvmf manifest.mf c2j.jar *.*

ok so at this point, everything went well but as invoke java:
java -jar c2j.jar

it gives me this:

Exception in thread "main" java.lang.NoClassDefFoundError: classes/C2JMain (wrong name: C2JMain)
at java.lang.blah.blah.blah.blah.blah
at java.lang.blah.blah.blah.blah.blah
at java.lang.blah.blah.blah.blah.blah
.......

what seems to be the problem here..

oh, and at the beginning of the java codes, i don't have the line:
package ;

Comments

  • stiffmaestrostiffmaestro Member Posts: 16
    CORRECTION
    : This is my directory structure:
    : D:javac2j_2_1
    : |
    : +----classes
    : | |
    : | +----my classes are here
    : | |
    : | +----C2JMain.class (this is my main class)
    : | |
    : | +----(other classes)
    : |
    : +----images
    : | |
    : | +----my images are here
    : |
    : +----lib
    : | |
    : | +----my jar files are here (none so far)
    : |
    : +----src
    ::::::::::::|
    ::::::::::::+----my JAVA FILES are here
    :
  • steevcocosteevcoco Member Posts: 7
    When you say:

    : Main-Class: classes.C2JMain

    you're saying that C2JMain is in package "classes" -- your C2JMain class would declare: [code]package classes;[/code] in the source file.

    This is conflicting with:

    : Class-Path: classes

    which requires that C2JMain is in the default package (not "classes").

    You should either remove the Class-Path entry which is superfluous and would be erronious if C2JMain is defined to be in package "classes"; or rename the Main-Class entry to just "C2JMain" if it's not in any package.

    Hopefully that made sense.


    You might find this other thread to be helpful too since it contains info on the Manifest and jar file specifications -- the thread's called "Errors running jar files".

    Good luck,
    - Steev.
Sign In or Register to comment.