views:

78

answers:

2

I'm trying to run a jar file that uses the YouTube Data API and I'm getting a NoClassDefFoundError for one of the API classes:

alt text

AuthenticationException.class is found in the gdata-core-1.0 jar:

alt text

The gdata-core-1.0 jar has been added to my classpath:

alt text

What am I doing wrong?

A: 

Perhaps you may not be having the jar in the classpath. The command prompt execution does not set the classpath. You will have to either do it by yourselves or give it on the fly while executing.

You should probably take a look at setting the MANIFEST file correct for the JAR file.

This post has a better description

Bragboy
It's highlighted in the last image
Anthony
Yes, but the exception you're getting is in the command prompt and not in the Eclipse. Correct me if I'm wrong
Bragboy
The classpath created in Eclipse is in the the jar file that I try to run. Do I need to set it again in the command prompt?
Anthony
Ah!! Got it!! There will be a file called MANIFEST.MF in the jar, you will have to set the classpath there!! See my updated answer
Bragboy
A: 

Does your jar-File contain the necessary libraries? When you execute your program outside of eclipse, the classpath defined in eclipse does not apply.

If no, you can take a look at this question which has been already answered.

cmaderthaner