views:

76

answers:

2

Hi,

I have an existing java project in Netbeans. I would like to start coding parts of it in Scala. I can add ".scala" files to the project but apparently they aren't compiled.

Can I somehow modify the existing Netbeans project settings in order to build java and scala sources together or do I need to create a new project and import the existing (java) sources?

Thanks

Martin

EDIT Sorry, I forgot to mention: I've installed the Scala-Plugin for netbeans, so compiling scala code is feasible. I can create a new (Scala) project and add both scala and java sources to it and it compiles perfectly. My question was if (and how) it's possible to migrate an existing "java-only" project towards such a "mixed" project.

+3  A: 

I don't think this is possible in the way you want it. You could however write an Ant build-script and let Netbeans execute it when building you application.

Otherwise I suggest to just create a new scala project and import it as *.jar library into your Java application. This keeps your project clean and nicely modularized.

halfdan
A: 

You will need to migrate to use something like Maven to do this for you, as Netbeans doesn't know how to compile Scala code. Maven can be configured to compile the .scala files first then the .java, resulting in your final compiled source.

Have a look here for the maven config.

gpampara
I forgot to mention the scala plugin. So Netbeans is perfectly able to compile scala files (resp. create an ANT build script for this purpose)
MartinStettner
You'll need to then update your ant build.xml to call scalac on the relevant files then, adding the class files to the java compile's classpath to produce the final class files.
gpampara