In this tutorial I will show you how to build an application by Maven that consists of Java and Scala source files. The project automatically uses the latest Scala 2.8-Snapshot until it’s released (Maven will look for the latest version of the Scala language each time you build it).
We will setup the project to use cross-compiling, so the java-classes can access Scala-classes and vice versa.
The good thing about maven projects is that you don’t need an IDE to start a project, thus remaining independent from certain IDE-features. In my next article, i will show how to configure eclipse to open the maven project. But for now i’ll show how to create the project from command line only.
If you’re impatient and just want to see the resulting pom.xml, you can also download the complete source:
Complete maven project


Build a mixed Scala 2.8/Java application from scratch with Maven [Eclipse Settings]
[EDIT 15.01.2011]
There have been changes since i wrote this article. Although i don’t have experiences with it until know, I would suggest using the m2eclipse-scala Plugin which solves some bugs that occur when using the regular M2Eclipse plugin.
Now i’m going to show you how to open the Maven project from Part 1 with Eclipse and what you have to care about when developing Scala/Java/Maven within Eclipse. It’s very easy to setup, but it took me a while so maybe it helps someone out there.
I’m using Eclipse version 3.5.2.
Before opening the Maven project with Eclipse, we need to download the M2Eclipse plugin and do some other adjustments to eclipse. M2Eclipse will handle all dependencies for our project and will build it automatically.
You can get the M2Eclipse-plugin from this update site:
http://m2eclipse.sonatype.org/sites/m2e
M2eclipse needs Eclipse to use the JDK as the JVM (the default setting is the JRE). So if you get an error from M2Eclipse saying that Eclipse should be run with the JDK, you have to alter the Eclipse.ini, inserting the path to your JDK.
Insert your JDK path before the vmargs. A sample Eclipse.ini for a windows system looks like this (when using Debian/Ubuntu, Eclipse seems to use the JDK automatically):
Read More »