'Importing classes into Scala worksheet
In my scala worksheet test.sc I define :
import com.tradedata.VolatilityInstance
test.sc exists at src/main/scala
In location src/main/scala I define :
package com.tradedata
class VolatilityInstance(intervalLength: Int, volatility: Double, beginDate: String, endDate: String) {
override def toString: String = {
this.beginDate
}
}
The filename for this class is VolatilityData.scala
VolatilityData.scala
exists at level src/main/scala/com/tradedata
When I attempt to run the worksheet I receive error :
Error:(1, 16) object VolatilityInstance is not a member of package com.tradedata
import com.tradedata.VolatilityInstance
If i define a new Scala object :
import com.tradedata.VolatilityInstance
object Tester extends App {
}
Tester object runs without issue.
I've tried re-building the project, invalidating the caches and restarting IntelliJ but cannot fix.
Is this a bug with the Scala worksheet ? How to import other classes into the Scala worksheet ?
Solution 1:[1]
I've tested your case in IntelliJ IDEA 2019.2.3 (Ultimate Edition) with Scala plugin 2019.2.28
Open test.sc
, click Scala worksheet settings
and change Run type
from REPL
to Plain
.
Solution 2:[2]
In Worksheet Settings
check Build project before run
It helps me
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | devrogs |
Solution 2 | Grey2k |