Problem with JAR Files

F

Frank Wood

I am developing a small front-end utilizing the AbsoluteLayout layout
from the AbsoluteLayout.jar file (which contains AbsoluteLayout.class
and AbsoluteConstraints.class), which comes from NetBeans 3.5.1.

My file is named Tray.java. I compile this down to Tray.class. I can
run this just fine from the command prompt with:

java.exe -classpath "c:\program
files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar";c:\tray
Tray

Of course, I can run it from the IDE in NetBeans as well with no
problems. My problem is attempting to run it all as a JAR file. I
create the jar file like (from the folder where the Tray*.class files
are located) this:

jar -cfm Tray.jar manifest.txt Tray*.class "c:\program
Files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

The manifest.txt file looks like this:

Main-Class: Tray
Class-Path: .;"c:\program
files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

Anyway, when I try to run the JAR file from the command prompt (as I
sit in the folder where the Tray.jar file I just created resides):

java -jar Tray.jar

I get:

C:\Tray>java -jar Tray.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
org/netbeans/lib/awte
xtra/AbsoluteLayout
at Tray.initComponents(Tray.java:85)
at Tray.<init>(Tray.java:15)
at Tray.main(Tray.java:522)

As you can probably tell, I'm fairly new at Java and have been able to
hurdle a number of things so far - but this one I haven't been able to
quite get over. I'm guessing that for whatever reason, it can't find
the AbsoluteLayout class that I need for my program to run.

Any help with this issue sure would be appreciated.

Thanks,
Frank Wood
 
A

Andrew Thompson

I am developing a small front-end
utilizing the AbsoluteLayout layout

Is that an oxymoron? ;-)
..which comes from NetBeans 3.5.1.

Another reason I am suspicious of
"advanced" D'n'D GUI designers.

AbsoluteLayout, harumph!
 
C

Chris Smith

Frank said:
The manifest.txt file looks like this:

Main-Class: Tray
Class-Path: .;"c:\program
files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

Two things:

1. The "Manifest-Version" attribute is REQUIRED in a JAR file manifest,
and should be set to a value of "1.0". Many utilities will not properly
read a manifest unless it has that attribute (aside from the general
concern that it's illegal).

2. The Class-Path attribute consists of a *whitespace* separated list of
*relative* paths to JAR files *only*. You're using a semicolon-
separated list of potentially absolute paths to some combination of JAR
files and directories; hence the inability of the JRE to figure out what
you're talking about.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
A

Andrew Thompson

...
1. The "Manifest-Version" attribute is REQUIRED in a JAR file manifest,
and should be set to a value of "1.0". Many utilities will not properly
read a manifest unless it has that attribute (aside from the general
concern that it's illegal).

Let me get this straight, suppose this
(*hypothetically*) were a manifest..

Manifest-Version: 0.1
Created-By: 1.0 PhySci.codes
Main-Class: FindIt

This would be _illegal_? Could you give
me links/search terms to research it?
 
C

Chris Smith

Andrew said:
Let me get this straight, suppose this
(*hypothetically*) were a manifest..

Manifest-Version: 0.1
Created-By: 1.0 PhySci.codes
Main-Class: FindIt

This would be _illegal_? Could you give
me links/search terms to research it?

Well, since there is no version 0.1 of the specification for JAR
Manifest files, yes I'd say it would be! How would the parsing
application know what expectations to make about the format of the
remainder of the file?

The manifest contents are defined at
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html... this defines
that Manifest-Version is required, and all Manifest-Version attributes
in that document are "1.0". I can't find a normative statement that the
attribute *must* be set to 1.0; but why would you want to lie about what
version of the spec you are following? The intent is clear enough that
this should be set to a correct value.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
A

Andrew Thompson

Andrew Thompson wrote: .... ...
Well, since there is no version 0.1 of the specification for JAR
Manifest files, yes I'd say it would be! How would the parsing
application know what expectations to make about the format of the
remainder of the file?

The manifest contents are defined at
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html... this defines
that Manifest-Version is required, and all Manifest-Version attributes
in that document are "1.0". I can't find a normative statement that the
attribute *must* be set to 1.0;

...hmmm, looking at this..
<http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Manifest Specification>
...and, this..
<http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Main Attributes>
"Manifest-Version:
Defines the manifest file version. The value is a legitimate
version number, as described in the above spec"

I'd say your right
..but why would you want to lie about what
version of the spec you are following?

(*hypothetically*) Someone may wish to indicate
a 'not-the-ridgy-didge' version in some (subtle)
way, and choose that as the way, ..for instance.
The intent is clear enough that
this should be set to a correct value.

Someone who created such a manifest programmatically
might have some quick coding to do (*hypothetically*).
 
C

Chris Smith

Andrew said:
..hmmm, looking at this..
<http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Manifest Specification>
..and, this..
<http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Main Attributes>
"Manifest-Version:
Defines the manifest file version. The value is a legitimate
version number, as described in the above spec"

I'd say your right

Actually, I interpret the phrase "is a legitimate version number, as
described in the above spec" to refer to the grammar rules for the
"version-number" production... so that doesn't yet prove that I'm right.
On further reflection, to determine that I'm right, you have to look at
a number of other sources that tell you specifically that the attribute
called "Manifest-Version" refers to conformance to a version of the
manifest spec; that's nowhere spelled out clearly in the spec itself.
Then you have to work from example; the spec doesn't have a clear
version number labeled anywhere, but all its examples contain a
"Manifest-Version: 1.0", so that indirectly implies that 1.0 is a
correct version.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
R

Roedy Green

I am developing a small front-end utilizing the AbsoluteLayout layout
from the AbsoluteLayout.jar file (which contains AbsoluteLayout.class
and AbsoluteConstraints.class), which comes from NetBeans 3.5.1.

Another approach might be simpler. Unpack the classes you need and
bundle them with your stuff all in one jar.
 
F

Frank Wood

Thanks for the help everyone--I was able to finally get it working on
my PC. However, once I moved the JAR file to another PC, and attempted
to run it, it failed.

I open up the JAR file with WinZip and see NO path information (except
for the manifest). In this JAR file, there is another JAR called
"AbsoluteLayout.jar". If I then open up this JAR file, it contains two
files (both class files), with a path of "org\netbeans\lib\awtextra".
The manifest has a class-path setting of "AbsoluteLayout.jar", which
of course, is there.

There error, from the Java Console is:

"java.lang.NoClassDefFoundError:eek:rg/netbeans/lib/awtextra/AbsoluteLayout"

Any ideas what could be causing the problem?

Thanks in advance for any help.

-Frank
 
S

Steven J Sobol

Frank Wood said:
Thanks for the help everyone--I was able to finally get it working on
my PC. However, once I moved the JAR file to another PC, and attempted
to run it, it failed.

I use AbsoluteLayout. I just include
org/netbeans/lib/awtextra/AbsoluteConstraints.class and
org/netbeans/lib/awtextra/AbsoluteLayout.class in my Jar files and things
work just fine.

Of course, I cheat. :) I create a JAR recipe from the IDE... since I'm
working in the IDE anyhow.

;P to those people who claimed this is a problem with AbsoluteLayout and
say that AbsoluteLayout sucks.

--
JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / (e-mail address removed)
Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/
"someone once called me a sofa, but i didn't feel compelled to rush out and buy
slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top