wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes NoClassDefFound Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFound" Watch "NoClassDefFound" New topic
Author

NoClassDefFound

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Hi all,

in my workspace I have three projects:

-- XML Editor (downloaded from Eclipse CVS), extended by me and this is a plug-in
-- project A
-- Common

Common contains functions that can be used both in XML Editor both in project A.

Both in ProjectA both in XMLEditor I have edited the build path and added the source folder of Common;
when launching ProjectA I have no problem, but when launching XML Editor (this is a plug-in, as said) I got error "NoClassDefFoundError".

The fact is class I want to use is imported in my class in the usual way:

import common.blablablabla

and till here I have no problem.

Problem arises only when launching XML Editor.

Can someone help me?

Thanks
Marco
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Do NOT add the source folder of another project, add the project.

If Project A depends on Project B, you could build the Project B and use the jar if you want but when developing it is faster to use the project reference.

HowTo:
Project->Build Path->Configure Build path:
[Tab] Projects
[BTN] Add : Select project.


Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Ove Lindström wrote:Do NOT add the source folder of another project, add the project.

If Project A depends on Project B, you could build the Project B and use the jar if you want but when developing it is faster to use the project reference.

HowTo:
Project->Build Path->Configure Build path:
[Tab] Projects
[BTN] Add : Select project.




Sorry, my bad explanation.
I added the project B using BuildPath->Tag Project->Add, but it does not work.
I also tried adding the jar file...nothing changed, same error.

Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Marco Rossi wrote:
Sorry, my bad explanation.
I added the project B using BuildPath->Tag Project->Add, but it does not work.
I also tried adding the jar file...nothing changed, same error.



Added what where? I think you are getting confused about who is depending on who.

Start by asking yourself this questions:
Where am I?
Do I have a pulse?
Where can I find what I need?
Have I added a dependency to that?
If I have, what is the accessor of that resource?

If Project A needs resources in Common, Project B needs to add Common to the build path. Not the other way around.
Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
No!

ProjectA needs resources that are in ProjectCommon, so I added ProjectCommon to build path of ProjectA...but it does not work.

But probably I found why.
ProjectA is a plug-in, when I start it from inside Eclipse with "Run as Eclipse Application" another instance of Eclipse opens and a runtime workspace is created.
Probably do I have to add ProjectCommon to this workspace?
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Marco Rossi wrote:No!

ProjectA needs resources that are in ProjectCommon, so I added ProjectCommon to build path of ProjectA...but it does not work.

But probably I found why.
ProjectA is a plug-in, when I start it from inside Eclipse with "Run as Eclipse Application" another instance of Eclipse opens and a runtime workspace is created.
Probably do I have to add ProjectCommon to this workspace?


If Project A is a plugin, extending XMLEditor plugin, and you start the Project A, then you need to make sure that the OSGi/Equinox-instance also takes the XMLEditor-plugin when starting.

Build path is when you build and affects if you see the code during development. Such as code completion of depending classes and packages.

When in Runtime, then you need to make sure that your deployment descriptor has the dependencies declared. Two different things.

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Ok!

When I start the plug-in as an Eclipse Application (from inside Eclipse) everything works fine, I have feature that I implemented and so on and so on.

During code writing I have code completion for classes that are inside ProjectCommon...but when I run my plug-in I get "NoClassDefFound"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFound
 
Similar Threads
Setting up project dependencies in eclipse
404 Not Found - Servlet runs locally (GlassFish), but Not Found on web site
Getting path info
duplicate maven artifacts
WSAD to Visual Source Safe