Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    1

    Unhappy Unanswered: How to make executetable jar file?

    Help!!

    [!!! is it possible to do that if classpath is not set ??!!!]

    I don't know why I need to enter the [Hello] directory to make a jar
    why I cannot specify the path instead of get into the Hello directory??
    I am not familiar with jar !!
    any jar expert can help me??


    success
    ================================================== ========
    C:\Hello>c:\j2sdk1.4.2_04\bin\jar cvfm c:\Hello\Hello.jar c:\Hello\META-INF\MANI
    FEST.MF *.class
    added manifest
    adding: Hello.class(in = 401) (out= 276)(deflated 31%)

    C:\Hello>c:\j2sdk1.4.2_04\bin\java -jar c:\Hello\Hello.jar
    Hello

    C:\Hello>

    fail
    ================================================== ========
    C:\>c:\j2sdk1.4.2_04\bin\jar cvfm c:\Hello\Hello.jar c:\Hello\META-INF\MANIFEST.
    MF c:\Hello\*.class
    added manifest
    adding: c:/Hello/Hello.class(in = 401) (out= 276)(deflated 31%)

    C:\>c:\j2sdk1.4.2_04\bin\java -jar c:\Hello\Hello.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: Hello

    C:\>

    thx all!

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    It's because the directory structure where you keep your java source and class files has to match package structure. When you add Hello.class (in the current directory) to a jar it is assumed to be in the default package. If you add /Hello/Hello.class to a jar it should be in the package named Hello.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •