• Post Reply Bookmark Topic Watch Topic
  • New Topic

javac can't find class in peer package  RSS feed

 
Tim Anderson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to compile some java code (using Ant, but a colleague is running into the same thing with JBuilder) but am having trouble getting past a reported error that the compiler can't find a constructor that is in a peer package. In other words, the file that won't compile and the file that has the constructor are in different sub-packages to the same parent package.

File calling constructor:




File containing construct and InternalEnum:



javac output:

[javac] C:\mainPackage\sub_a\ClassOne.java:15: cannot resolve symbol
[javac] symbol : constructor ClassTwo (mainPackage.sub_b.ClassTwo.InternalEnum,mainPackage.sub_b.ClassTwo.InternalEnu m,java.lang.String,java.lang.String,java.lang.String,java.lang.String,mainPackag e.sub_a.ClassThree)
[javac] location: class mainPackage.sub_b.ClassTwo
[javac] ClassTwo message = new ClassTwo(
[javac] ^
[javac] 1 error
[javac] Compile failed; see the compiler error output for details.


I'm using java sdk 1.4.2_07 and my colleague is using 1.4.2_01b16.

Has anybody else seen anything like this with either Ant or JBuilder?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the portion of ClassOne shown above, you don't have new ClassTwo(...) anywhere, so you're not showing the part of the code that the message applies to; and in the portion of ClassTwo you're showing us, there are no constructors at all, so of course ClassOne can't say new ClassTwo(...) with any arguments at all.

In the process of abstracting this, you've obscured all the useful info. So let's start over. Show us the exact line of code where the error is being reported (line 15 in ClassOne) and then show us all the constructors in ClassTwo. That should be enough for us to tell you what's going on.
 
Tim Anderson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I guess I'm overly sensitive to giving out actual code as my company has had three attempts to try to take this program from us.

Here's the actual lines of code that I feel should get this cleared up.

Calling code:


The code that I'm trying to instantiate:


And finally the javac output:

[javac] C:\rat\jtim\src\mil\navair\jreap\connection\TDMTargetPackage.java:439: cannot resolve symbol
[javac] symbol : constructor InputMessage (mil.navair.jreap.connection.InputMessage.MsgSource,mil.navair.jreap.connection.InputMessage.JREAPType,java.lang.String,java.lang.String,java.lang.String,java.lang.String,mil.navair.jreap.connection.TDMAddress)
[javac] location: class mil.navair.jreap.connection.InputMessage
[javac] InputMessage message = new InputMessage (
[javac] ^


Hope this helps.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears from this code and error message that you've got two different (although perhaps similar, if not identical!) classes named "TDMAddress"; one in the "connection" package, and one in the "controller" package. InputMessage's contructor wants the controller one, but you're passing in an instance of the connection one.

What was that loud banging sound? Hey, don't do that -- you'll hurt your head!
 
Tim Anderson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry again. Yet another typo. The import line in the code with the constructor is wrong. It should read:

import mil.navair.jreap.connection.TDMAddress;

Sorry again for the typo. Thanks for helping out!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!