tags:

views:

223

answers:

3

I've been reading up on Scala a lot recently and I really want to get into it. I do my Java web development from within Eclipse with Tomcat as my preferred server and I'd like to keep it that way. I've tried the Scala Eclipse plugin but it's safe to say, it isn't there yet. I had to uninstall it because it simply ins't working. On top of that, it doesn't seem to provide anything for doing web projects (I could be wrong there).

Since Scala is a compiled language just like Java is, I was wondering if it's possible to simply swap out Java with Scala, as in, where I'd normally would create Java classes I would now be able to create Scala classes instead? Maybe even mix Java and Scala?

Is there anyone out there who's been able to set up a decent Scala workflow in Eclipse for web development without the dreaded "official" Scala Eclipse Plugin?

PS: I've tried the Play framework (I think it recently added Scala support) but it simply isn't for me. I like my classes compiled and to use JSP's for my views.

+4  A: 

You don't say anything about what version of the Scala IDE for Eclipse you were using, or what you tried to do to resolve your issues. I suggest that before changing your workflow you head over to http://groups.google.com/group/scala-ide-user and see if we can help you out.

Miles Sabin
I'm using the Scala plugin with Eclipse Galileo. I've been trying different versions of the plugin over the past few months. Most of the time I get the following error when trying to open a Scala file: "An error has occurred. See error log for more details. java.lang.ExceptionInInitializerError". I've tried clean Eclipse installations (I work on an Ubuntu 9.10 desktop).I was hoping that the Scala plugin would actually "add" Scala functionality to the existing Java development tools so that using Scala within Java projects would be a straight forward thing.
Luke
You have an issue with your installation: what you're describing is definitely *not* the expected behaviour. Maybe it's a bug (in which case a detailed report would be helpful). Maybe it's an unfortunate interaction with your environment ... from what you say it's impossible to tell.If you want to try and resolve the problem then head over to http://groups.google.com/group/scala-ide-user as I suggested earlier.
Miles Sabin
+2  A: 

As Miles said, you should give us the version of Eclipse you are working with.

I'm also new to Scala and found difficult to work through Eclipse. I was using Eclipse Galileo 3.5.2 and found specially long to compile all the scala libraries. I switched to IntelliJ (IDEA 9.0.2) and I'm much more confortable now. I recomend trying it although it's more a personal matter.

Even so, I agree, the plugins are not there yet specially for web development. The great news is that you can use everything you have in Java and mix it with Scala. Since Scala is compiled to Java BitCode, they are totally compatible. See Combining Scala and Java.

When writing in Scala you always have (almost) all the Java libraries at your service plus anything you have created before. You will have to be carefull with the types (i.e. primitive types) but it normally works out very well.

Skuge
I was looking at IDEA the other day. I haven't tried it yet. Might do soon.
Luke
+4  A: 

Since Scala is a compiled language just like Java is, I was wondering if it's possible to simply swap out Java with Scala, as in, where I'd normally would create Java classes I would now be able to create Scala classes instead?

Yes, absolutely. That's one of Scala's big advantages over some other JVM languages.

Maybe even mix Java and Scala?

Yes, absolutely. That's one of Scala's big advantages over some other JVM languages.

Make sure you have familiarity with the Java and Scala collections libraries (and that you keep them straight -- if you're planning using advanced Scala features on Java collections, definitely use a Scala 2.8 release candidate). Also make sure you're faimilar with the @BeanProperty annotation -- it can simplify your Scala coding somewhat.

Ken Bloom
Thanks for that. Can you elaborate on how do add Scala to your existing Java projects in Eclipse?
Luke
@Luke. I can't answer that. I don't use Eclipse, but several other people here seem to be answering that aspect of the question, so I thought I'd elaborate on the area that they're not covering.
Ken Bloom