Since I’ve been trying to have Scala help with simplifying Java code, I’ve been looking into the possibility of having java and scala classes in the same project(under netbeans and Eclipse). While Netbeans doesnt seem to have this functionality available yet, someone pointed out the “scala nature” functionality in Eclipse.
Basically, if you have a Java project, you can do a right click -> Scala -> Add Scala Nature. Doing so puts the scala libraries on the classpath and converts the project to a Scala project. This is supposed to allow one to have both Java and scala code in the same project and have them refer to each other.
I’ve been trying this. Here’s what I have:
1. Scala objects are not visible from java classes, only scala classes are, this is apparently a known problem. I dont see why it would a problem allowing the access of the object’s methods like one would access static methods in Java.
2. When I right click -> Scala -> add Scala Nature for a JavaEE project, it does not add the scala libraries to the project classpath. So this does not solve my problem of having Scala code in Java Web apps.
3. So adding Scala nature only works for regular Java Projects for now.
Its a start though, and if we can access Scala objects and have JavaEE web apps which scala code in them, it’ll bring us one step closer to JavaEE nirvana :-).