Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project
java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project [message #183381] Thu, 07 December 2006 18:29 Go to next message
Eclipse UserFriend
Originally posted by: daniel.hartman.ieee.org

Hello all,

I am receiving java.lang.NoClassDefFoundError when I attempt to access a
static method from a class that exists in another project.

Here is a little background: I am running Eclipse 3.2.0, and I am
experimenting with the development of a simple RCP that reads in an XML
file and displays the XML structure and content in an Explorer-like view
(extending ViewPart).

Here is the problem with a little more detail: When I attempt to
reference a static method from a class in another project, I receive the
java error: java.lang.NoClassDefFoundError. However, if I create a
simple java console application in a new project and reference the
static method from the class (still located in a different project), it
works fine.

I've confirmed that my "Java Build Path" settings are identical between
my RCP and my java console application, i.e., the settings under the
"Projects" tab and the "Order and Exports" tab are identical. I've also
confirmed that the import statements are correct.

If I drag my package which contains the class with the static method
into the source directory of my RCP project, then everything works fine.

Here is my Package Explorer structure:

My RCP:

PROJECT: com.by6.fm
PACKAGE: com.by6.fm
CLASS: <lots of classes>
PACKAGE: com.by6.fm.model
CLASS: <lots of classes>
CLASS: Group.java <-- unable to call the static method

A project which contains the static method:

PROJECT: com.by6.utils
PACKAGE: com.by6.utils
CLASS: Path.java <-- static method inside this class

A java console application which provided a sanity check:

PROJECT: TEST
PACKAGE: TEST
CLASS: TEST.java <-- successfully able to call the static method

I am new to Eclipse, but not new to java programming, so I would
appreciate any ideas to try. Currently, I am downloading the latest
version of Eclipse (to be read: desperation).

Many thanks in advance.

Sincerely,

Dan
Re: java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project [message #183390 is a reply to message #183381] Thu, 07 December 2006 19:32 Go to previous messageGo to next message
Paul A. Rubin is currently offline Paul A. RubinFriend
Messages: 188
Registered: July 2009
Senior Member
D. Hartman wrote:
> Hello all,
>
> I am receiving java.lang.NoClassDefFoundError when I attempt to access a
> static method from a class that exists in another project.
>
> Here is a little background: I am running Eclipse 3.2.0, and I am
> experimenting with the development of a simple RCP that reads in an XML
> file and displays the XML structure and content in an Explorer-like view
> (extending ViewPart).
>
> Here is the problem with a little more detail: When I attempt to
> reference a static method from a class in another project, I receive the
> java error: java.lang.NoClassDefFoundError. However, if I create a
> simple java console application in a new project and reference the
> static method from the class (still located in a different project), it
> works fine.
>
> I've confirmed that my "Java Build Path" settings are identical between
> my RCP and my java console application, i.e., the settings under the
> "Projects" tab and the "Order and Exports" tab are identical. I've also
> confirmed that the import statements are correct.
>
> If I drag my package which contains the class with the static method
> into the source directory of my RCP project, then everything works fine.
>
> Here is my Package Explorer structure:
>
> My RCP:
>
> PROJECT: com.by6.fm
> PACKAGE: com.by6.fm
> CLASS: <lots of classes>
> PACKAGE: com.by6.fm.model
> CLASS: <lots of classes>
> CLASS: Group.java <-- unable to call the static method
>
> A project which contains the static method:
>
> PROJECT: com.by6.utils
> PACKAGE: com.by6.utils
> CLASS: Path.java <-- static method inside this class
>
> A java console application which provided a sanity check:
>
> PROJECT: TEST
> PACKAGE: TEST
> CLASS: TEST.java <-- successfully able to call the static method
>
> I am new to Eclipse, but not new to java programming, so I would
> appreciate any ideas to try. Currently, I am downloading the latest
> version of Eclipse (to be read: desperation).
>
> Many thanks in advance.
>
> Sincerely,
>
> Dan

Probably dumb questions, but does Group.java import com.by6.utils.Path,
and is com.by6.utils on the list of required projects on the build path
for com.by6.fm?

/Paul
Re: java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project [message #183398 is a reply to message #183390] Thu, 07 December 2006 21:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.hartman.ieee.org

Paul Rubin wrote:

> D. Hartman wrote:
>
>> Hello all,
>>
>> I am receiving java.lang.NoClassDefFoundError when I attempt to access
>> a static method from a class that exists in another project.
>>
>> Here is a little background: I am running Eclipse 3.2.0, and I am
>> experimenting with the development of a simple RCP that reads in an
>> XML file and displays the XML structure and content in an
>> Explorer-like view (extending ViewPart).
>>
>> Here is the problem with a little more detail: When I attempt to
>> reference a static method from a class in another project, I receive
>> the java error: java.lang.NoClassDefFoundError. However, if I create
>> a simple java console application in a new project and reference the
>> static method from the class (still located in a different project),
>> it works fine.
>>
>> I've confirmed that my "Java Build Path" settings are identical
>> between my RCP and my java console application, i.e., the settings
>> under the "Projects" tab and the "Order and Exports" tab are
>> identical. I've also confirmed that the import statements are correct.
>>
>> If I drag my package which contains the class with the static method
>> into the source directory of my RCP project, then everything works fine.
>>
>> Here is my Package Explorer structure:
>>
>> My RCP:
>>
>> PROJECT: com.by6.fm
>> PACKAGE: com.by6.fm
>> CLASS: <lots of classes>
>> PACKAGE: com.by6.fm.model
>> CLASS: <lots of classes>
>> CLASS: Group.java <-- unable to call the static method
>>
>> A project which contains the static method:
>>
>> PROJECT: com.by6.utils
>> PACKAGE: com.by6.utils
>> CLASS: Path.java <-- static method inside this class
>>
>> A java console application which provided a sanity check:
>>
>> PROJECT: TEST
>> PACKAGE: TEST
>> CLASS: TEST.java <-- successfully able to call the static method
>>
>> I am new to Eclipse, but not new to java programming, so I would
>> appreciate any ideas to try. Currently, I am downloading the latest
>> version of Eclipse (to be read: desperation).
>>
>> Many thanks in advance.
>>
>> Sincerely,
>>
>> Dan
>
>
> Probably dumb questions, but does Group.java import com.by6.utils.Path,
> and is com.by6.utils on the list of required projects on the build path
> for com.by6.fm?
>
> /Paul
>

Hi Paul,

Not a dumb question, and yes I performed the import, and its on the
build path. Very frustrating.

Cheers.
Re: java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project [message #183545 is a reply to message #183398] Fri, 08 December 2006 22:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

D. Hartman wrote:
> Paul Rubin wrote:
>
>> D. Hartman wrote:
>>
>>> Hello all,
>>>
>>> I am receiving java.lang.NoClassDefFoundError when I attempt to
>>> access a static method from a class that exists in another project.
>>>
>>> Here is a little background: I am running Eclipse 3.2.0, and I am
>>> experimenting with the development of a simple RCP that reads in an
>>> XML file and displays the XML structure and content in an
>>> Explorer-like view (extending ViewPart).
>>>
>>> Here is the problem with a little more detail: When I attempt to
>>> reference a static method from a class in another project, I receive
>>> the java error: java.lang.NoClassDefFoundError. However, if I create
>>> a simple java console application in a new project and reference the
>>> static method from the class (still located in a different project),
>>> it works fine.
>>>
>>> I've confirmed that my "Java Build Path" settings are identical
>>> between my RCP and my java console application, i.e., the settings
>>> under the "Projects" tab and the "Order and Exports" tab are
>>> identical. I've also confirmed that the import statements are correct.
>>>
>>> If I drag my package which contains the class with the static method
>>> into the source directory of my RCP project, then everything works fine.
>>>
>>> Here is my Package Explorer structure:
>>>
>>> My RCP:
>>>
>>> PROJECT: com.by6.fm
>>> PACKAGE: com.by6.fm
>>> CLASS: <lots of classes>
>>> PACKAGE: com.by6.fm.model
>>> CLASS: <lots of classes>
>>> CLASS: Group.java <-- unable to call the static method
>>>
>>> A project which contains the static method:
>>>
>>> PROJECT: com.by6.utils
>>> PACKAGE: com.by6.utils
>>> CLASS: Path.java <-- static method inside this class
>>>
>>> A java console application which provided a sanity check:
>>>
>>> PROJECT: TEST
>>> PACKAGE: TEST
>>> CLASS: TEST.java <-- successfully able to call the static method
>>>
>>> I am new to Eclipse, but not new to java programming, so I would
>>> appreciate any ideas to try. Currently, I am downloading the latest
>>> version of Eclipse (to be read: desperation).
>>>
>>> Many thanks in advance.
>>>
>>> Sincerely,
>>>
>>> Dan
>>
>>
>> Probably dumb questions, but does Group.java import
>> com.by6.utils.Path, and is com.by6.utils on the list of required
>> projects on the build path for com.by6.fm?
>>
>> /Paul
>>
>
> Hi Paul,
>
> Not a dumb question, and yes I performed the import, and its on the
> build path. Very frustrating.
>
> Cheers.
RCP projects are normally plugin projects. Plugin projects must depend
on other plugin projects and not on simple Java projects. You
com.by6.utils project needs to be converted to a plugin project and your
com.by6.fm project needs to specify the com.by6.utils project as a
dependency in its manifest file.
Re: java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project [message #183695 is a reply to message #183545] Sun, 10 December 2006 21:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.hartman.ieee.org

David Wegener wrote:

> D. Hartman wrote:
>
>> Paul Rubin wrote:
>>
>>> D. Hartman wrote:
>>>
>>>> Hello all,
>>>>
>>>> I am receiving java.lang.NoClassDefFoundError when I attempt to
>>>> access a static method from a class that exists in another project.
>>>>
>>>> Here is a little background: I am running Eclipse 3.2.0, and I am
>>>> experimenting with the development of a simple RCP that reads in an
>>>> XML file and displays the XML structure and content in an
>>>> Explorer-like view (extending ViewPart).
>>>>
>>>> Here is the problem with a little more detail: When I attempt to
>>>> reference a static method from a class in another project, I receive
>>>> the java error: java.lang.NoClassDefFoundError. However, if I
>>>> create a simple java console application in a new project and
>>>> reference the static method from the class (still located in a
>>>> different project), it works fine.
>>>>
>>>> I've confirmed that my "Java Build Path" settings are identical
>>>> between my RCP and my java console application, i.e., the settings
>>>> under the "Projects" tab and the "Order and Exports" tab are
>>>> identical. I've also confirmed that the import statements are correct.
>>>>
>>>> If I drag my package which contains the class with the static method
>>>> into the source directory of my RCP project, then everything works
>>>> fine.
>>>>
>>>> Here is my Package Explorer structure:
>>>>
>>>> My RCP:
>>>>
>>>> PROJECT: com.by6.fm
>>>> PACKAGE: com.by6.fm
>>>> CLASS: <lots of classes>
>>>> PACKAGE: com.by6.fm.model
>>>> CLASS: <lots of classes>
>>>> CLASS: Group.java <-- unable to call the static method
>>>>
>>>> A project which contains the static method:
>>>>
>>>> PROJECT: com.by6.utils
>>>> PACKAGE: com.by6.utils
>>>> CLASS: Path.java <-- static method inside this class
>>>>
>>>> A java console application which provided a sanity check:
>>>>
>>>> PROJECT: TEST
>>>> PACKAGE: TEST
>>>> CLASS: TEST.java <-- successfully able to call the static
>>>> method
>>>>
>>>> I am new to Eclipse, but not new to java programming, so I would
>>>> appreciate any ideas to try. Currently, I am downloading the
>>>> latest version of Eclipse (to be read: desperation).
>>>>
>>>> Many thanks in advance.
>>>>
>>>> Sincerely,
>>>>
>>>> Dan
>>>
>>>
>>>
>>> Probably dumb questions, but does Group.java import
>>> com.by6.utils.Path, and is com.by6.utils on the list of required
>>> projects on the build path for com.by6.fm?
>>>
>>> /Paul
>>>
>>
>> Hi Paul,
>>
>> Not a dumb question, and yes I performed the import, and its on the
>> build path. Very frustrating.
>>
>> Cheers.
>
> RCP projects are normally plugin projects. Plugin projects must depend
> on other plugin projects and not on simple Java projects. You
> com.by6.utils project needs to be converted to a plugin project and your
> com.by6.fm project needs to specify the com.by6.utils project as a
> dependency in its manifest file.

Thank you. That makes sense, but it just seems strange. Apparently, I
don't understand the concept of a "project" yet. It seems to me that I
should be able to include classes from other projects into a RCP. In
particular, I want to separate some of my reusable utility classes from
my RCP application.

So here is the Eclise newcomer question: if I create a second RCP
application, how would I include classes from my utilities package
(com.by6.utils)? Please bear in mind that I don't think that the utils
package is appropriate as a plug-in, i.e., currently it consists of just
one class that provides static methos to manipulate path strings.

Many thanks for the insight.
Re: java.lang.NoClassDefFoundError: Accessing a Method from a Class in Another Project [message #183747 is a reply to message #183695] Mon, 11 December 2006 04:49 Go to previous message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

D. Hartman wrote:
> David Wegener wrote:
>
>> D. Hartman wrote:
>>
>>> Paul Rubin wrote:
>>>
>>>> D. Hartman wrote:
>>>>
>>>>> Hello all,
>>>>>
>>>>> I am receiving java.lang.NoClassDefFoundError when I attempt to
>>>>> access a static method from a class that exists in another project.
>>>>>
>>>>> Here is a little background: I am running Eclipse 3.2.0, and I am
>>>>> experimenting with the development of a simple RCP that reads in an
>>>>> XML file and displays the XML structure and content in an
>>>>> Explorer-like view (extending ViewPart).
>>>>>
>>>>> Here is the problem with a little more detail: When I attempt to
>>>>> reference a static method from a class in another project, I
>>>>> receive the java error: java.lang.NoClassDefFoundError. However,
>>>>> if I create a simple java console application in a new project and
>>>>> reference the static method from the class (still located in a
>>>>> different project), it works fine.
>>>>>
>>>>> I've confirmed that my "Java Build Path" settings are identical
>>>>> between my RCP and my java console application, i.e., the settings
>>>>> under the "Projects" tab and the "Order and Exports" tab are
>>>>> identical. I've also confirmed that the import statements are
>>>>> correct.
>>>>>
>>>>> If I drag my package which contains the class with the static
>>>>> method into the source directory of my RCP project, then everything
>>>>> works fine.
>>>>>
>>>>> Here is my Package Explorer structure:
>>>>>
>>>>> My RCP:
>>>>>
>>>>> PROJECT: com.by6.fm
>>>>> PACKAGE: com.by6.fm
>>>>> CLASS: <lots of classes>
>>>>> PACKAGE: com.by6.fm.model
>>>>> CLASS: <lots of classes>
>>>>> CLASS: Group.java <-- unable to call the static method
>>>>>
>>>>> A project which contains the static method:
>>>>>
>>>>> PROJECT: com.by6.utils
>>>>> PACKAGE: com.by6.utils
>>>>> CLASS: Path.java <-- static method inside this class
>>>>>
>>>>> A java console application which provided a sanity check:
>>>>>
>>>>> PROJECT: TEST
>>>>> PACKAGE: TEST
>>>>> CLASS: TEST.java <-- successfully able to call the static
>>>>> method
>>>>>
>>>>> I am new to Eclipse, but not new to java programming, so I would
>>>>> appreciate any ideas to try. Currently, I am downloading the
>>>>> latest version of Eclipse (to be read: desperation).
>>>>>
>>>>> Many thanks in advance.
>>>>>
>>>>> Sincerely,
>>>>>
>>>>> Dan
>>>>
>>>>
>>>>
>>>> Probably dumb questions, but does Group.java import
>>>> com.by6.utils.Path, and is com.by6.utils on the list of required
>>>> projects on the build path for com.by6.fm?
>>>>
>>>> /Paul
>>>>
>>>
>>> Hi Paul,
>>>
>>> Not a dumb question, and yes I performed the import, and its on the
>>> build path. Very frustrating.
>>>
>>> Cheers.
>>
>> RCP projects are normally plugin projects. Plugin projects must
>> depend on other plugin projects and not on simple Java projects. You
>> com.by6.utils project needs to be converted to a plugin project and
>> your com.by6.fm project needs to specify the com.by6.utils project as
>> a dependency in its manifest file.
>
> Thank you. That makes sense, but it just seems strange. Apparently, I
> don't understand the concept of a "project" yet. It seems to me that I
> should be able to include classes from other projects into a RCP. In
> particular, I want to separate some of my reusable utility classes from
> my RCP application.
>
> So here is the Eclise newcomer question: if I create a second RCP
> application, how would I include classes from my utilities package
> (com.by6.utils)? Please bear in mind that I don't think that the utils
> package is appropriate as a plug-in, i.e., currently it consists of just
> one class that provides static methos to manipulate path strings.
>
> Many thanks for the insight.
The Eclipse approach is to create multiple plugins. Each plugin
contains some related set of classes. The relationship is normally some
logical subset of the application. Some examples would be core,
internal, UI, utility.

At the simplest level, a plugin is a jar file with a manifest.mf file
that defines the packages that the plugin makes available to dependent
plugins. This makes it very easy to create a plugin from an existing
jar file. In fact, there is even a wizard for creating a plugin from an
existing jar file. You can also convert an existing Java project to a
plugin project by right clicking on the project and selecting PDE
tools->convert project to Plugin project.
Previous Topic:How to do plain file diff/merge?
Next Topic:Is it work with Linux envirment
Goto Forum:
  


Current Time: Fri Apr 26 05:51:16 GMT 2024

Powered by FUDForum. Page generated in 0.09880 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top