• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Help on Creating a Jar file for my JavaBean

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a package called voiceexpert which contains three classes: Disease, DiagnosingEngine and Symptoms which is a JavaBean. Symptoms makes use of Disease and DiagnosingEngine objects.

voiceexpert is stored in the directory: c:\diagapp3

I compiled Symptoms.java as below:
c:\diagapp3> javac -d . Symptoms.java

The class files for Disease.java, DiagnosingEngine.java and Symptoms.java are placed in the directory: voiceexpert.

I created a Manifest.txt file inside c:\diagapp3 containing the following:

Main-Class:voiceexpert.voiceexpert.Symptoms

Name:voiceexpert/Symptoms.class

Java-Bean:True

I later created the jar file with the command:

jar cfm jjj.jar Manifest.txt *

But, I am having the error message: invalid header field

What can I do to remove this error?

Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There should be a space after the colon
e.g. Main-Class:voiceexpert.voiceexpert.Symptoms should be Main-Class: voiceexpert.voiceexpert.Symptoms
Also your manifest file should end in a new line or carriage return.

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another one is I think you should not have new line between the property in manifest file.

For more details see Manifest

 
femi lami
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried what you advised but still having the same problems.
Could you please explain what the following mean and how to actually follow these guidelines to jar my files?

section: *header +newline
nonempty-section: +header +newline
newline: CR LF | LF | CR (not followed by LF)
header: name : value
name: alphanum *headerchar
value: SPACE *otherchar newline *continuation
continuation: SPACE *otherchar newline
alphanum: {A-Z} | {a-z} | {0-9}
headerchar: alphanum | - | _
otherchar: any UTF-8 character except NUL, CR and LF
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

femi lami wrote:My code is to be used in a third-party application and that is why it does not contain a main method.



I don't think this is the cause of the error, but if your code doesn't contain a main method then you don't need a Main-Class entry in your jar file.
 
femi lami
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have removed the Main-Class header, yet the same error still persisted.
What do you think I can do to get over this problem?
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Impossible to tell without more details.
Post the exact (copy paste) contents of your manifest file.
 
femi lami
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The contents of the Manifest file I created is:

Manifest-Version: 1.0

Created-By: 1.6.0 (Sun Microsystems Inc.)

Name: voiceexpert/Symptoms.class

Java-Bean: True

This gave the error mesage: invalid header field name: Manifest-Version
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic