Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Compile Problem involving Dependencies Date: Sat, 29 Oct 2011 17:24:42 +0000 (UTC) Organization: UK Free Software Network Lines: 64 Message-ID: References: NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1319909082 24266 84.45.235.129 (29 Oct 2011 17:24:42 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Sat, 29 Oct 2011 17:24:42 +0000 (UTC) User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9301 On Sat, 29 Oct 2011 17:06:46 +0000, Novice wrote: > I'm having a problem compiling some Java code which I _think_ has to do > with a dependency issue that I don't fully understand. I wonder if > someone here can enlighten me? > > I have a class named FooApplet which is defined as public and extends > JApplet. FooApplet makes use of a class I wrote called WrapUtils, which > is simply a public class. WrapUtils in turn makes use of other classes I > wrote called ErrorUtils and CountUtils, both of which are simply public > classes. > > I'm using Eclipse 3.7 and FooApplet compiles just fine. However, > WrapUtils shows compile errors at every mention of ErrorUtils and > CountUtils. ErrorUtils and CountUtils both compile cleanly. > > The suggested fixes for the errors in WrapUtils include generating an > import statement for ErrorUtils and CountUtils, even though they are in > the same package as WrapUtils. When I click on the option to generate > those imports, the import statement is NOT added to WrapUtils and the > errors for ErrorUtils and CountUtils remain. The red "x" remains on > WrapUtils both in the editor and in Package Explorer. Why does Eclipse > not see the ErrorUtils and CountUtils? All of the classes are public and > all of WrapUtils, CountUtils and ErrorUtils are in the same package, > although it is a different package than the one containing FooApplet? > > So, to recap, we have: > > com.foo.FooApplet (public extends JApplet) > - invokes com.foo.utilities.WrapUtils (public) > - invokes com.foo.utilities.CountUtils (public) > - invokes com.foo.utilities.ErrorUtils (public) > > All references to CountUtils and ErrorUtils in WrapUtils are flagged as > compile errors: "CountUtils cannot be resolved". > > What stupid mistake am I making? Is this a dependency error? Or is the > fact that the methods in WrapUtils, CountUtils and ErrorUtils are all > static that are the source of the problem? You don't mention where the classes are in your directory structure or the package name of FooApplet. I would assume that, relative to where Eclipse is run you'd find that - FooApplet contains the "package com.foo;" declaration - all three other sources contain the "package com.foo.utilities;" declaration. - the path names of the .java files relative to the Eclipse root are: com/foo/FooApplet.java com/foo/utilities/WrapUtils.java com/foo/utilities/CountUtils.java com/foo/utilities/WrapUtils.java If your package declarations and relative pathnames differ, thats most likely the cause. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |