- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Problems with scala package
Thu, 2010-09-09, 15:16
Hi all, I've a dummy question.
I've this class in a file:
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
And I've this object in another file:
object Test {
def NOT(b: Bit): Bit = Bit(!b.getValue)
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
Those files are into the same package. But I can't reference it. The follow error appear:
init:
deps-jar:
Compiling 1 source file to /media/ACUENCA/Labs/Test/build/classes
No known dependencies. Compiling everything
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: type Bit
def NOT(b: Bit): Bit = Bit(!b.getValue)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: type Bit
def NOT(b: Bit): Bit = Bit(!b.getValue)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: value Bit
def NOT(b: Bit): Bit = Bit(!b.getValue)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:7: error: not found: type Bit
val b1, b2, b3, b4: Bit = Bit(true)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:7: error: not found: value Bit
val b1, b2, b3, b4: Bit = Bit(true)
5 errors found
/media/ACUENCA/Labs/Test/nbproject/build-impl.xml:418: The following error occurred while executing this line:
/media/ACUENCA/Labs/Test/nbproject/build-impl.xml:233: Compilation failed because of an internal compiler error; see the error output for details.
GENERACIÓN INCORRECTA (total time: 8 seconds)
But, If I put it all together It works!
object Test {
def NOT(b: Bit): Bit = Bit(!b.getValue)
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
I hope that someone could help me, I'll appreciate it.
Regards,
--
TSU. Amador Cuenca
I've this class in a file:
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
And I've this object in another file:
object Test {
def NOT(b: Bit): Bit = Bit(!b.getValue)
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
Those files are into the same package. But I can't reference it. The follow error appear:
init:
deps-jar:
Compiling 1 source file to /media/ACUENCA/Labs/Test/build/classes
No known dependencies. Compiling everything
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: type Bit
def NOT(b: Bit): Bit = Bit(!b.getValue)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: type Bit
def NOT(b: Bit): Bit = Bit(!b.getValue)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: value Bit
def NOT(b: Bit): Bit = Bit(!b.getValue)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:7: error: not found: type Bit
val b1, b2, b3, b4: Bit = Bit(true)
/media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:7: error: not found: value Bit
val b1, b2, b3, b4: Bit = Bit(true)
5 errors found
/media/ACUENCA/Labs/Test/nbproject/build-impl.xml:418: The following error occurred while executing this line:
/media/ACUENCA/Labs/Test/nbproject/build-impl.xml:233: Compilation failed because of an internal compiler error; see the error output for details.
GENERACIÓN INCORRECTA (total time: 8 seconds)
But, If I put it all together It works!
object Test {
def NOT(b: Bit): Bit = Bit(!b.getValue)
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
I hope that someone could help me, I'll appreciate it.
Regards,
--
TSU. Amador Cuenca
Thu, 2010-09-09, 15:57
#2
Re: Problems with scala package
I'm using Netbeans with the scala plugin.
Look at the complete structure:
//Main.scala file
package comcircuit
object Main {
def NOT(b: Bit): Bit = Bit(!b.getValue)
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
//Bit.scala file
package comcircuit
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
I created a new project with just these 2 files and it don't works!
I have included a screenshot. You can see the netbean project and the files.
Regards,
--
TSU. Amador Cuenca
Look at the complete structure:
//Main.scala file
package comcircuit
object Main {
def NOT(b: Bit): Bit = Bit(!b.getValue)
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
//Bit.scala file
package comcircuit
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
I created a new project with just these 2 files and it don't works!
I have included a screenshot. You can see the netbean project and the files.
Regards,
--
TSU. Amador Cuenca
Thu, 2010-09-09, 16:27
#3
Re: Problems with scala package
oops, replied to wrong address again :@
It works fine under eclipse. I don't know much about NetBeans, is it ok to have a period (.) in the project name? Could this maybe lead to some wrong project configuration?
Try cleaning your project. If it doesn't work I'm afraid I won't be able to help you any further.
--Jakob
On 9 September 2010 16:47, Amador Antonio Cuenca <sphi02ac [at] gmail [dot] com> wrote:
It works fine under eclipse. I don't know much about NetBeans, is it ok to have a period (.) in the project name? Could this maybe lead to some wrong project configuration?
Try cleaning your project. If it doesn't work I'm afraid I won't be able to help you any further.
--Jakob
On 9 September 2010 16:47, Amador Antonio Cuenca <sphi02ac [at] gmail [dot] com> wrote:
I'm using Netbeans with the scala plugin.
Look at the complete structure:
//Main.scala file
package comcircuit
object Main {
def NOT(b: Bit): Bit = Bit(!b.getValue)
def main(args: Array[String]): Unit = {
val b1, b2, b3, b4: Bit = Bit(true)
println(b1 AND b2)
println(NOT(b1) AND b2 OR b3)
}
}
//Bit.scala file
package comcircuit
case class Bit(v: Boolean) {
private var value: Boolean = v
def getValue: Boolean = value
def setValue(v: Boolean): Unit = if (v != value) value = v
def AND(b: Bit): Bit = Bit(this.value & b.getValue)
def OR(b: Bit): Bit = Bit(this.value | b.getValue)
}
I created a new project with just these 2 files and it don't works!
I have included a screenshot. You can see the netbean project and the files.
Regards,
--
TSU. Amador Cuenca
Thu, 2010-09-09, 16:37
#4
Re: Problems with scala package
Well,
The problem is with netbeans, I've to clean & build the project. Then, It works. I think it's some plugin's bug.
Thanks for answer shortly.
Regards,
--
TSU. Amador Cuenca
The problem is with netbeans, I've to clean & build the project. Then, It works. I think it's some plugin's bug.
Thanks for answer shortly.
Regards,
--
TSU. Amador Cuenca
Thu, 2010-09-09, 16:47
#5
Re: Problems with scala package
On 09/09/2010 16:16, Amador Antonio Cuenca wrote:
> init:
> deps-jar:
> Compiling 1 source file to /media/ACUENCA/Labs/Test/build/classes
> No known dependencies. Compiling everything
> /media/ACUENCA/Labs/Test/src/Demo/Circuit/Test.scala:4: error: not found: type Bit
> def NOT(b: Bit): Bit = Bit(!b.getValue)
What is strange, is that it compiles only one source file, ie. apparently it doesn't
compile Bit.scala
Not sure why, I don't know NetBeans.
Are you using eclipse? I once refactored a class from one package to another in eclipse and my code wouldn't compile. It turned out that eclipse just moved my source file to another directory but didn't change the package declaration itself.
On 9 September 2010 16:16, Amador Antonio Cuenca <sphi02ac [at] gmail [dot] com> wrote: