Results 1 to 9 of 9

Thread: Create .JAR

  1. #1
    marksu988 is offline Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    Default Create .JAR

    Hi all i've this situation

    Java Code:
    - C:\
      - javagraf
          MANIFEST.txt
          - hofstra
             - matsrc
                 *.class
                 - expr
                      *.class
    Main class is located into "matsrc" directory.
    I want to creare .jar file in "javagraf" directory.

    My MANIFEST:
    Manifest-Version: 1.0
    Created-By: XXX
    Main-Class: hofstra\matscr\mainClass.class
    cd C:\javafagraf
    jar cmf MANIFEST.txt MyJar.jar ???
    I've tryed with:
    jar cmf MANIFEST.txt MyJar.jar hofstra\matscr\*.class hofstra\matscr\expr\*.class
    but it don't work.

    Where is the problem?
    Last edited by DarrylBurke; 08-02-2012 at 05:44 PM. Reason: Solved

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Create .JAR

    Just use the directory name.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    marksu988 is offline Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    Default Re: Create .JAR

    Quote Originally Posted by Tolls View Post
    Just use the directory name.
    Uhm, and isnt it?

    jar cmf MANIFEST.txt MyJar.jar hofstra\matscr\*.class hofstra\matscr\expr\*.class
    I used relative path to include all .class files (including files in expr directory with second istruction).
    But it do not work when i try
    java -jar MyJar.jar.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: Create .JAR

    What error message do you get? Open a command prompt window, change to the folder with the jar file and enter:
    java -jar MyJar.jar

    copy the console contents here.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Create .JAR

    Quote Originally Posted by marksu988 View Post
    Uhm, and isnt it?
    No.
    jar cmf MANIFEST.txt MyJar.jar hoftsra

    In other words, just use the directory name.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    marksu988 is offline Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    Default Re: Create .JAR

    Quote Originally Posted by Norm View Post
    What error message do you get? Open a command prompt window, change to the folder with the jar file and enter:
    java -jar MyJar.jar
    [..]
    Paste here.
    C:\javagrafzip>jar cmf MANIFEST.txt MyJar.jar hofstra (as Tolls suggest)

    At now jar size is 66KB so i suppose that it is consistent.

    C:\javagrafzip>java -jar MyJar.jar

    Errore: impossibile trovare o caricare la classe principale Graf.class
    Error: can't find or load main class Graf.class [eng]

    I've tryed to modify my MANIFEST's main class row as:

    Main-Class: Graf.class
    or
    Main-Class: hofstra\matscr\mainClass.class
    or
    Main-Class: hofstra.matscr.mainClass.class
    I've also tryed to change MANIFEST's extension as .MF (as some guides suggest)

    result is the same: "can't find or load main class".

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: Create .JAR

    Look in the jar file with a zip utulity and see what the path to the Graf.class file is.
    Is the Graf class in a package? If so, that is where the class file needs to be and that is what needs to be on the Main-Class: entry.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Create .JAR

    The classname does not have the file extension on the end.
    No '.class'.
    And, as Norm says, should contain the full package name (with '.', not path separators).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    marksu988 is offline Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

Similar Threads

  1. Help me create this GUI please
    By atrodeyo in forum AWT / Swing
    Replies: 8
    Last Post: 04-26-2012, 06:32 PM
  2. How to create a JFrame window and create a circle.
    By tehsumo in forum AWT / Swing
    Replies: 3
    Last Post: 02-27-2012, 05:06 PM
  3. create id
    By daisy in forum JDBC
    Replies: 15
    Last Post: 03-16-2011, 10:34 AM
  4. jsp to create xml
    By mcajavaprogramer in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-05-2010, 01:22 PM
  5. Create XML From XSD
    By Jack in forum XML
    Replies: 1
    Last Post: 07-09-2007, 01:56 AM

Posting Permissions

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