f



java.lang.NoClassDefFoundError

Hi,

When running my app from within NetBeans it works perfectly but when I 
start the dist jar version (all up to date) I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: FilmGUI/jar

'java' is in the classpath and the same thing happens regardless of 
whether I use the jre or jdk version of java.exe (OS: Win 2000 Pro, JDK 
1.5.0.01, JRE 1.5.0.01, NetBeans 4.0).

Strangely if I run the dist jar file from the command line I get the error 
specified but I also have a shortcut on my desktop to the jar file in 
question and if I launch that with a double-click it runs with all the 
functionality working ok except it doesn't 'externally launch my default 
browser with a specific URL'. My project compiling sources has Browser.jar 
added to it which contains Neosoft's Browser class (which will launch the 
system default browser with an URL). Could the Browser class be somehow 
not making it into the dist and then causing the error?

Thanks,

MS
0
MS
3/17/2005 8:14:49 PM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

6 Replies
470 Views

Similar Articles

[PageSpeed] 37

On 3/17/2005 at 3:14:49 PM, MS wrote:

> When running my app from within NetBeans it works perfectly but when I
> start the dist jar version (all up to date) I get this error:
> 
> Exception in thread "main" java.lang.NoClassDefFoundError: FilmGUI/jar
> 
> 'java' is in the classpath and the same thing happens regardless of
> whether I use the jre or jdk version of java.exe (OS: Win 2000 Pro, JDK
> 1.5.0.01, JRE 1.5.0.01, NetBeans 4.0).
> 
> Strangely if I run the dist jar file from the command line I get the
> error specified but I also have a shortcut on my desktop to the jar file
> in question and if I launch that with a double-click it runs with all
> the functionality working ok ...

Then perhaps there is something wrong with the command line you are using.
Pity you did not include it in your message.

> except it doesn't 'externally launch my default browser with a specific
> URL'. My project compiling sources has Browser.jar added to it which
> contains Neosoft's Browser class (which will launch the system default
> browser with an URL). Could the Browser class be somehow not making it
> into the dist and then causing the error?

That is certainly a possibility.  Have you looked at the JAR file contents
to see if it is there?

-- 
Regards,

John McGrath
0
ng69 (117)
3/18/2005 12:30:43 AM
>>except it doesn't 'externally launch my default browser with a specific
>>URL'. My project compiling sources has Browser.jar added to it which
>>contains Neosoft's Browser class (which will launch the system default
>>browser with an URL). Could the Browser class be somehow not making it
>>into the dist and then causing the error?
> 
> 
> That is certainly a possibility.  Have you looked at the JAR file contents
> to see if it is there?

Thanks John.

No I hadn't looked -- now I have and it is not there. I can't seem to work 
out how to make sure it gets added. Can you help?

Thanks and Regards,

MS
0
MS
3/18/2005 12:04:29 PM
MS <matthews@mailsnare.---nojunktakeout---.net> writes:

> Exception in thread "main" java.lang.NoClassDefFoundError: FilmGUI/jar

This indicates you typed

java FilmGUI.jar

instead of either

java -jar FilmGUI.jar

or

java -classpath FilmGUI.jar some.MainClass
0
3/18/2005 3:10:13 PM
On 3/18/2005 at 7:04:29 AM, MS wrote:

> > > Could the Browser class be somehow not making it into 
> > > the dist and then causing the error?

> > That is certainly a possibility.  Have you looked at the JAR file
> > contents to see if it is there?

> No I hadn't looked -- now I have and it is not there. I can't seem to
> work out how to make sure it gets added. Can you help?

I don't use NetBeans, so I cannot provide a lot of help in creating the
JAR file.  However, I think you have two choices:  Either you store all of
the third-party classes (e.g. Browser) in the JAR file itself, or you
place a directive in the JAR file to include another JAR on your classpath.

It sounds like you are building your JAR file using your IDE, so how you
would include the third-party classes in it depends on NetBeans.  I
presume that you have somehow told NetBeans about the third-party classes,
and that it was including it them on your classpath when you ran the
program from within NetBeans.  The IDE I use (JBuilder) has an "Archive
Builder" facility which presents the list of third party libraries and
allows you to chooses whether to include them with a simple combo box.  I
do not know if NetBeans has something similar.

The other choice is to add a "Class-Path" entry in the manifest of the JAR
that you create, and include the third-party classes, usually in a
separate JAR file, along with your application JAR.  Again, how you would
do that depends on the tool you are using to create the JAR file.

Of course, all of this can be done with a text editor and the "jar" tool
that comes with the Sun JDK, or with a tool such as "Ant".  Such tools are
usually more flexible, but perhaps not as easy to use.  IDE tools tend to
make it easier to do the more commonplace tasks.

-- 
Regards,

John McGrath
0
ng69 (117)
3/18/2005 3:24:37 PM
Many thanks for your detailed response John.

> I don't use NetBeans, so I cannot provide a lot of help in creating the
> JAR file.  However, I think you have two choices:  Either you store all of
> the third-party classes (e.g. Browser) in the JAR file itself, or you
> place a directive in the JAR file to include another JAR on your classpath.

Ok.


> It sounds like you are building your JAR file using your IDE, so how you
> would include the third-party classes in it depends on NetBeans.  I
> presume that you have somehow told NetBeans about the third-party classes,
> and that it was including it them on your classpath when you ran the
> program from within NetBeans.  The IDE I use (JBuilder) has an "Archive
> Builder" facility which presents the list of third party libraries and
> allows you to chooses whether to include them with a simple combo box.  I
> do not know if NetBeans has something similar.

Yes, I've added the jar file to the compiling sources. But I can't find 
how to add the 3rd party classes to my achive. Surely this is possible in 
the IDE! The netbeans help seems to say all I need do is what I've done, 
so either it's wrong or -more likely- I've missed something.


> The other choice is to add a "Class-Path" entry in the manifest of the JAR
> that you create, and include the third-party classes, usually in a
> separate JAR file, along with your application JAR.  Again, how you would
> do that depends on the tool you are using to create the JAR file.
> 
> Of course, all of this can be done with a text editor and the "jar" tool
> that comes with the Sun JDK, or with a tool such as "Ant".  Such tools are
> usually more flexible, but perhaps not as easy to use.  IDE tools tend to
> make it easier to do the more commonplace tasks.

Understood and thanks.

I've found a netbeans mailing list and have emailed that, as it will be 
useful to know how to do this from the IDE.

Cheers,

MS
0
MS
3/18/2005 4:42:02 PM
Thanks Tor.

What you say is true, however the problem with browser.jar -as discussed 
with John- remains. It's just a question of when the exception is thrown 
or 'displayed' -- immediately displayed with 'java FilmGUI.jar' or thrown 
when the method using the openUrl() (held in browser.jar) is run if using 
'java -jar FilmGUI.jar'.

Cheers,

MS
0
MS
3/19/2005 2:31:42 PM
Reply: