Compilation error using scala classes in java maven project

I have a java maven project, I installed the scala plugin for eclipse and added the scala resource to my project. Now I have written some custom scala actors and some other utility classes. I use these scala classes in my java code. when writing code, it does not cause any errors. But when I do maven clean / build, it throws a compilation error as below

11/8/11 10:45:23 AM : [ERROR] ............\Simple.java:[86,10] cannot find symbol symbol : variable ExecutorObject location: class com.ms.scala.Simple 11/8/11 10:45:23 AM : [INFO] 2 errors 11/8/11 10:45:23 AM : [INFO] ------------------------------------------------------------- 11/8/11 10:45:23 AM : Build errors for Project; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project : Compilation failure 

Eclipse IDE: helios -3.5, scala - 2.9.2, which comes with the plugin

I assume there is a custom compiler configuration for this? I also have another question about newbies

how do you start a scala actor right in java and send him a message? all i see is the act () method. i want to do it

 actor { CustomActor ! Message } 

in java

thanks sanre6

0
source share
2 answers

In the first part, did you add the scala compilation step to your maven pom? Have you added maven-scala-plugin to your pom?

In the second part, Mirko says, there is no easy way to define an actor in Java. You will need to define it in Scala, but then you can run it and send messages to it in Java.

Just call start() on the instance, and then you can pass messages to it using! method. This will be available in java, but it is called $bang .

+3
source

Go to http://scala-tools.org/mvnsites/maven-scala-plugin/example_java.html and use pom directly for the first test. I did this with:

  • A Scala class "ScalaUtils" inside src/main/scala
  • The java class inside src/main/java that uses "ScalaUtils"

It is important to add Scala compilation to the correct phase before java is compiled:

 <execution> <phase>process-resources</phase> 
+2
source

Source: https://habr.com/ru/post/908984/


All Articles