Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: Jar facility appears broken

  1. #1
    Junior Member j831526's Avatar
    Join Date
    Jun 2014
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Jar facility appears broken

    java -version
    java version "1.7.0_60"
    Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
    Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode

    This is all being done on an iMac (Maverick opsys) from the tcsh shell.

    I built a jarfile (jarbuild is my python script but the executed jar command is printed) while positioned in the Brenda directory:

    jarbuild Brenda
    Executing: jar cv0mf Manifest.txt Brenda.jar *.class
    added manifest
    adding: Brenda.class(in = 2063) (out= 2063)(stored 0%)
    adding: BrendaController$1.class(in = 1170) (out= 1170)(stored 0%)
    adding: BrendaController.class(in = 2382) (out= 2382)(stored 0%)
    adding: BrendaITC.class(in = 507) (out= 507)(stored 0%)
    adding: BrendaModel$1.class(in = 700) (out= 700)(stored 0%)
    adding: BrendaModel.class(in = 3251) (out= 3251)(stored 0%)
    adding: BrendaView$1.class(in = 851) (out= 851)(stored 0%)
    adding: BrendaView.class(in = 3418) (out= 3418)(stored 0%)
    adding: Message.class(in = 908) (out= 908)(stored 0%)
    adding: Trace.class(in = 898) (out= 898)(stored 0%)
    adding: U$1.class(in = 612) (out= 612)(stored 0%)
    adding: U.class(in = 2203) (out= 2203)(stored 0%)
    adding: messageID.class(in = 1787) (out= 1787)(stored 0%)
    adding: messageSrc.class(in = 903) (out= 903)(stored 0%)
    adding: state.class(in = 801) (out= 801)(stored 0%)

    My Manifest file has one line which ends with a newline character: Main-Class: Brenda

    When I try and execute:

    java -jar Brenda.jar
    Error: Could not find or load main class Brenda

    Also, when I try and execute jar -t Brenda.jar to see the contents of my jarfile, the command simply hangs.

    Thanx for any suggies - Charlie


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar facility appears broken

    Look at the contents of the jar file with a zipfile utility to check it. What is in the manifest file?
    Is the Brenda class in a package?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member j831526's Avatar
    Join Date
    Jun 2014
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Jar facility appears broken

    As shown above the manifest file contains the single line: Main-Class: Brenda
    And Brenda.class is in the jarfile which I confirmed using the Unarchiver.

    Charlie

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar facility appears broken

    You missed this question:
    Is the Brenda class in a package?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member j831526's Avatar
    Join Date
    Jun 2014
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Jar facility appears broken

    Sorry, yes - the package name is also Brenda.

    Charlie

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar facility appears broken

    The name of the class used in the manifest should include the package: Brenda.Brenda

    Try this command for a quick test: java -cp Brenda.jar Brenda.Brenda
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member j831526's Avatar
    Join Date
    Jun 2014
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Jar facility appears broken

    Same result:
    java -cp Brenda.jar Brenda.Brenda
    Error: Could not find or load main class Brenda.Brenda

    BTW: what's the p option? It doesn't show up in jar -help.

    Thanx - Charlie

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar facility appears broken

    Is the Brenda.class file in the Brenda folder in the jar file? The path to the location of the class file should match the package it is in.

    Sorry, I don't know what the p option is.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member j831526's Avatar
    Join Date
    Jun 2014
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Jar facility appears broken

    Yes, all the source files, classfiles, and the manifest are in the Brenda directory.

    Charlie

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar facility appears broken

    The MANIFEST.MF file should be in the META-INF directory.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member j831526's Avatar
    Join Date
    Jun 2014
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Jar facility appears broken

    It is. That's where the jar command placed it. The manifest I passed to the jar command is in my Brenda directory with everything else. The jar command modifies the manifest file and saves the result as MANIFEST.MF in the META-INF directory it creates within the jar file. This appears correct as far as I know.

    Charlie

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar facility appears broken

    You said:
    Yes, all the source files, classfiles, and the manifest are in the Brenda directory.
    I was asking about the contents of the jar file. Is the above quote about what is in the jarfile or was it about where the files are on the PC? Where they are on the PC is not important.

    For the files in the jar file, where is the Brenda.class file located?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 14
    Last Post: December 25th, 2013, 02:04 PM
  2. Help with a broken for loop?
    By Iantaylora in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 19th, 2013, 06:11 PM
  3. [SOLVED] Taking a square root in Java, answer appears as 0.0. Why?
    By r19ecua in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 30th, 2012, 11:47 AM