Bad class file error when using Scala 2.8.x (2.8.0 and 2.8.1) in Javafx 1.x (1.2 and 1.3.1) - scala

When trying to import scala.Option in a javafx script, I get the following javafxc error:
cannot access scala.Option.$anonfun$orNull$1
bad class file: scala/Option$$anonfun$orNull$1.class(scala:Option$$anonfun$orNull$1.class)
undeclared type variable: A1
Please remove or make sure it appears in the correct subdirectory of the classpath.
import scala.Option;
I am using Scala 2.8.1, Javafxc 1.3.1_b101, JVM 1.6.0_21-b06, OS Ubuntu 10.10. The same code was working in Scala 2.7.7 .
Later edit:
The same error is reported in case I import scala.immutable.Seq/List/Traversable/Iterable . I have tried the imports in a default Netbeans 6.9.1 JavaFX project which has in the classpath only scala-library.jar.

It reminded me first of #4067, but this one looks quite different.
I would suggest that you try to reproduce the error with 2.8.1 or 2.9 trunk, maybe it is fixed?

Related

import scala.io.StdIn

I'm using Eclipse ScalaIDE and for some reason I'm not able to
import scala.io.StdIn
I'm getting a red squiggly that tells me:
object StdIn is not a member of package io
And I'm seeing that it's not in that scala.io jar file. The ScalaDoc, however says it should be there. I've tried both scala 2.10.4 and 2.11.5. I've used the Eclipse ScalaIDE to create the scala project and I've also created an sbt eclipse project directly using the scalasbt.plugin which I use all the time to manage ScalaIDE dependencies.
sbt "eclipse with-source=true"
Neither way is getting it.
I'm currently taking the Coursera Reactive Programming course and an assignment file has this import. I'm able do compile the project with sbt directly, but Eclipse ScalaIDE is not doing the job. Any clues? There may be good reason why not to use scala.io.StdIn, but my question is why can I not get it to import in the ScalaIDE?
thank you
scala.io.StdIn is new in scala 2.11.x and does not exist in previous versions.
The problem you are likely encountering is that ScalaIDE is not picking up the scala version you are specifying. Since you say that you tried it with 2.10.4, it probably still has that cached or set somewhere and it's failing because it cannot find the specified class.

opencv 3.0.0 java imread_0 undefined

I am trying to develop an application using java opencv 3.0.0-beta using scala.
I am getting a runtime error:
java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_1(Ljava/lang/String;)J
While researching the cause i have created the following simple application the exhibits similar behaviour:
import reflect._
import org.opencv.core.Core
import org.opencv.core.Mat
import org.opencv.core.CvType
import org.opencv.imgcodecs.Imgcodecs
object main extends Application {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
val what = "something.png"
val mat = Imgcodecs.imread(what)
Imgcodecs.imwrite("something_else.png", mat)
}
The major difference is that, if run as "sbt run" it performs as expected. if the appropriate lines are removed from the above the code fails in REPL.
I suspect that this issue is related to the original issue, but have no proof.
If i look at the memory map of the JVM in both cases i have the expected libs loaded.
If the code is inspected i find no definition of org.opencv.imgcodecs.Imgcodecs.imread_1
I am quite lost as to where to go next in diagnosing this issue.
Is there anyone who has come across this issue?
Thanks
i haven't used openCV3.0 yet, as it has major changes and breaks opencv 2.4.x code , are you supplying the library path to
sbt run
add
javaOptions in run += "-Djava.library.path=lib/opencv/"
to your build.sbt file or pass on cmd line
sbt run -Djava.library.path=lib/opencv/
opencv folder should have your files that gets generated along with your jar file
i have java bindins for 2.4.9 , 2.4.10 and 3.0.0 for java 7 and 8 in this git repo if you need them
git#gitlab.com:opencv/java_lib.git

intellij scala plugin won't compile after package rename

I'm using intellij 14.0.2 build#ic-139.659 and scala plugin 1.2.1
Im working on a basic project for a while and everything went well until i rename a package name.
Since then im getting this error and i cant compile and run the program
Error:(10, 8) not found: object Repo
import Repo._
^
When i'm generating the same code to eclipse it compile and run well.
Is that a bug or i`m doing something wrong ?
thanks,
miki

Orbeon Forms - Compile error in IntelliJ IDEA - util.Try

I am trying to compile Orbeon Forms in IntelliJ IDEA 14.0.1 Community Edition, but I am getting compile errors.
Checked out the branch origin/4.7-ce
Opened the project with IntelliJ
Got on error: Load error: undefined path variables. MESSAGE is undefined. Fix it
Fixed the MESSAGE error by entering C:\temp as the value. I don't know if this matters.
Installed the Scala and File Watchers plugins
Configured the Java SDK as jdk1.7.0_09
Removed the scala-sdk that was referencing non-existent scala compiler, library, reflect jars in my $USER_HOME\.ivy2\cache directory.
Installed the Scala 2.10.3 SDK and configured as a library in the project.
Make Project
Got 94 errors, all related to the util and xml packages. I would have expected the packages to be scala.util and scala.xml.
Example errors:
orbeon-forms\src\main\scala\org\orbeon\oxf\common\PEVersion.scala
Error:(34, 8) object Try is not a member of package util<br/>
import util.Try
orbeon-forms\src\main\scala\org\orbeon\oxf\fb\AlertsAndConstraintsOps.scala<br/>
Error:(46, 9) type mismatch;<br/>
found : scala.xml.Elem<br/>
required: org.orbeon.saxon.om.NodeInfo<br/>
toXML currentLang<br/>
What am I doing wrong?
I was able to fix this error by changing the import from:
import util.Try to import scala.util.Try
There were other files that had the same issue with the scala.xml package.
The full list of files I changed is:
src\main\scala\org\orbeon\oxf\common\PEVersion.scala
src\main\scala\org\orbeon\oxf\fr\mongodb\MongoDBPersistence.scala
src\main\scala\org\orbeon\oxf\fr\process\ProcessInterpreter.scala
src\main\scala\org\orbeon\oxf\fr\process\SimpleProcess.scala
src\main\scala\org\orbeon\oxf\fr\process\XFormsActions.scala
src\main\scala\org\orbeon\oxf\xforms\action\XFormsAPI.scala
src\main\scala\org\orbeon\oxf\xforms\analysis\ElementAnalysis.scala
src\main\scala\org\orbeon\oxf\xforms\analysis\PathMapXPathAnalysis.scala
src\main\scala\org\orbeon\oxf\xforms\control\controls\XFormsInputControl.scala
src\main\scala\org\orbeon\scaxon\XML.scala
src\test\scala\org\orbeon\oxf\common\VersionTest.scala

"is not a member of package" error when importing package in Scala with SBT

(Relative beginner here, please be gentle...)
I've got a Scala program that I can build with sbt. I can (from within sbt) run compile and test-compile with no errors. I've defined a package by putting package com.mycompany.mypackagename at the top of several .scala files. When I do console to get a Scala REPL, this happens:
scala> import com.mycompany.mypackagename._
<console>:5: error: value mypackagename is not a member of package com.mycompany
import com.mycompany.mypackagename._
Any variation of this also fails. When I just do import com.mycompany I get no problems.
I thought that running the Scala console from within sbt would properly set the classpath based on the current projects? What (completely obvious) thing am I missing?
I ran into this same problem, and then I realized I was running scala 2.10.0 on commandline, and IDEA was using Scala 2.9.2. So the fix was to change both to use the same version, and:
sbt clean
What will happen if you import actual class name instead of wildcard.
import com.mycompany.mypackagename.ActualClassName