I am a beginner learning Scala. I am on Windows 8.1, using Scala IDE 4.0.0 and Gradle with scala and eclipse plugins to create a project, in which I want to use scala.swing and javax.media packages. I add both libraries as dependencies in build.gradle, only javax.media works.
The steps I have done are:
create folders and files as follows
foo |-src |-main |-scala |-Foo.scala |-build.gradle
where
build.gradle
is Gradle build script andFoo.scala
is a Scala script, as shown below<<build.gradle>>
apply plugin: 'scala' apply plugin: 'eclipse' repositories { mavenCentral() } dependencies { compile 'org.scala-lang:scala-swing:2.10.4' compile 'javax.media:jmf:2.1.1e' }
<<Foo.scala>>
import javax.media.Player //no error import scala.swing._ //error: object swing is not a member of package scala class Foo { }
using command line, navigate to
foo
and rungradle eclipse
- in Scala IDE, do
import -> General -> Existing Projects into Workspace -> Browse -> Foo
Then, I get an error at Foo.scala, line 2, which reads object swing is not a member of package scala
. And the Referenced Libraries
list on the left panel shows only jmf-2.1.1e.jar
for javax.media
, as shown in the picture below
<<.classpath>>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src/main/scala"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER" exported="true"/>
<classpathentry kind="lib" path="C:/Users/mm/.gradle/caches/modules-2/files-2.1/javax.media/jmf/2.1.1e/fe9287a362578bfb8b7b9dba42af0ec80a297abb/jmf-2.1.1e.jar" exported="true"/>
</classpath>
I have tried to configure Eclipse's build path and add scala-swing.jar
manually, which works okay, but then I have to do this every time I run the Gradle build script. Please suggest why scala-swing-something.jar
did not get imported by Gradle, and how to fix it.
This is the logging message after running $ gradle dependencies
:
$ gradle dependencies
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Compile classpath for source set 'main'.
+--- org.scala-lang:scala-swing:2.10.4
| \--- org.scala-lang:scala-library:2.10.4
\--- javax.media:jmf:2.1.1e
default - Configuration for default artifacts.
+--- org.scala-lang:scala-swing:2.10.4
| \--- org.scala-lang:scala-library:2.10.4
\--- javax.media:jmf:2.1.1e
runtime - Runtime classpath for source set 'main'.
+--- org.scala-lang:scala-swing:2.10.4
| \--- org.scala-lang:scala-library:2.10.4
\--- javax.media:jmf:2.1.1e
testCompile - Compile classpath for source set 'test'.
+--- org.scala-lang:scala-swing:2.10.4
| \--- org.scala-lang:scala-library:2.10.4
\--- javax.media:jmf:2.1.1e
testRuntime - Runtime classpath for source set 'test'.
+--- org.scala-lang:scala-swing:2.10.4
| \--- org.scala-lang:scala-library:2.10.4
\--- javax.media:jmf:2.1.1e
zinc - The Zinc incremental compiler to be used for this Scala project.
No dependencies
BUILD SUCCESSFUL
Total time: 11.159 secs