java.lang.NoClassDefFoundError message even after adding jar to theclasspath!!!

S

shivaraj

Hi,

I have a java program which expects a different class (BeanHome.class)
file from a jar. I have added this jar into my classpath. But still I
am getting "java.lang.NoClassDefFoundError: com/test/base/BeanHome"
error. I feel still its something to do with classpath settings.
Please let me know what might be wrong here.
the jar which is having BeanHome class is "service.jar" which is there
in C: drive.
classpath is set using :

set CLASSPATH=%CLASSPATH%;C:\service.jar;

command.

Let me know if I am missing something.
 
L

Lew

shivaraj said:
Hi,

I have a java program which expects a different class (BeanHome.class)
file from a jar. I have added this jar into my classpath. But still I
am getting "java.lang.NoClassDefFoundError: com/test/base/BeanHome"
error. I feel still its something to do with classpath settings.
Please let me know what might be wrong here.
the jar which is having BeanHome class is "service.jar" which is there
in C: drive.
classpath is set using :

set CLASSPATH=%CLASSPATH%;C:\service.jar;

command.

You don't need that last semicolon. Also, a drive's root directory is not an
optimal place to put such artifacts.
Let me know if I am missing something.

So far, the command to run the program.

How did you phrase the command?

Based on indirect evidence, I'm guessing it was something like

java com/test/base/BeanHome

Was that it?

If so, replace the slashes with periods:

java com.test.base.BeanHome

Also, instead of setting CLASSPATH you can also, and often should, use

java -cp %PROJECTROOT%;C:/service.jar com.test.base.BeanHome

Here I'm imagining an envar PROJECTROOT set to the parent directory of com/.
 
M

Manfred Rosenboom

Is BeanHome the remote home interface of an EJB?
If yes, you are writing an EJB client. The setup
of the class path depends on which AS you use.
Please tell us, which AS you use.

Best,
Manfred
 
S

shivaraj

it's a beast to track down.
Seehttp://mindprod.com/jgloss/runerrormessages.html#NOCLASSDEFFOUNDERROR


Hi All,
Thanks for your reply. Though i could not figure out the actual cause
of the problem it got fixed when i used ant framework. I wrote a ant
build file and mentioned this jar with the path and it worked!!! Not
sure what i was missing earlier but its working fine now.
 
A

Andrew Thompson

shivaraj said:
...Though i could not figure out the actual cause
of the problem it got fixed when i used ant framework.

That was a good strategy. I abhor locking important information
into 'some IDE'. If you have an Ant build file, almost any IDE
worth having, should be able to build the project.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top