scala

How to run Scala compiled classes from a different directory

Under Windows, I can run a Scala script from a different directory using a batch script like: Hello.bat: @scala "%~dp0Hello.scala" %* (%~dp0 will be translated to the path where the batch file is) So I can call it like this: c:\somedir>path\to\scala\script\Hello Hello World! c:\somedir>path\to\scala\script\Hello Moon Hello Moon! ...

The best Scala API reference?

In my PHP years http://www.php.net was my best friend. I think that the clean and complete API reference on that website is one of the best features of the language. It references every function available with examples and comments from the community. I want to ask all the Scala programmers out there: Is there something like this f...

How to sum 2 joda-time DateTime values (one containing a date and a zero time and another containing a time and a zero date)?

In a Scala 2.8 program of mine I use joda-time with its scala-time wrapper. I've got 2 DateTime values, one for a date (with zero time fields) and one for time (with zero date fields) (the reason of separation is a storage architecture). How do I get another DateTime value with both date and time parts set from a source pair? ...

How to disribute and maintain java/scala program over a Linux cluster ?

I have a small cluster of Linux machines and an account on all of them. I have ssh access to all of them with no-password login. How can I use actors or other Scala's concurrency abstraction to achieve distribution ? What is the simplest path? Does some library can distribute the processes for me? The computers are unreliable, they can...

Why isn't this Scala method documented in Scaladocs?

I've been told that Scaladocs is the best source for Scala API documentation: http://www.scala-lang.org/api/current/index.html I've found an example using scala.io.Source.fromURL(url).getLines The example works, but fromURL is not in that site. Where can I find a more exhaustive documentation on the methods available? ...

Scala Swing Date Picker

Looking to convert Java Swing DatePicker into Scala but facing difficulty in one area of the code. How should I probably translate the if (x > 6) part into scala? Original Java taken from http://www.roseindia.net/tutorial/java/swing/datePicker.html for (int x = 0; x < button.length; x++) { final int selection = x; ...

SQL DSL for Scala

I am struggling to create a SQL DSL for Scala. The DSL is an extension to Querydsl, which is a popular Query abstraction layer for Java. I am struggling now with really simple expressions like the following user.firstName == "Bob" || user.firstName == "Ann" As Querydsl supports already an expression model which can be used here I dec...

How to set an empty value in a lift select element?

Hi people, I am trying to set an empty value (as a first choice) in a lift select element: SHtml.select(("", "") :: (MyObject.findAll(By(MyObject.creator, User.currentUser.open_!.id))), ... However it gives me this error: error: type mismatch; found: List[(String, java.lang.Object)] required: Seq[(String, String)] Any ideas? Thanks...

How to build a jar in NetBeans 6.9?

When I press "build project" it NetBeans builds, as far as I could find, separate class files. How can I set it to build them into a jar file? Even better it'd be if I can build several applications (all separately runnable from command line) from one project. I code Scala 2.8. ...

Calling Java from Scala: protected constructor

This compiles without error on Scala 2.8.0 final: import javax.swing.tree.TreePath object A extends Application { val path1 = new TreePath() val path2 = new TreePath(path1, "foo") } However, on execution I get: java.lang.IllegalAccessError: tried to access method javax.swing.tree.TreePath.<init>()V from class A$ at A$.<init>...

Scala framework for a Rest API Server?

Hi, We are thinking on moving our Rest API Server (it is inside the web service, on Symfony PHP) to Scala for several reasons: speed, no overhead, less cpu, less code, scalability, etc. I did't know Scala until several days ago but I've been enjoying what I've been learning these days with the Scala book and all the blog posts and quest...

What is the most succinct Scala way to reverse a Map?

What is the most succinct Scala way to reverse a Map? The Map may contain non-unique values. EDIT: The reversal of Map[A, B] should give Map[B, Set[A]] (or a MultiMap, that would be even better). ...

Scala: Why does Seq.contains take an Any argument, instead of an argument of the sequence type?

So for example why does List(1,2,3,4).contains("wtf") even compile? Wouldn't it be nice if the compiler rejected this? ...

UIManager Font Setting

font = new Font("San Serif", Font.PLAIN, 24) val keys = UIManager.getDefaults().keys() while (keys.hasMoreElements()) { val key = keys.nextElement() val value = UIManager get key if (value.isInstanceOf[FontUIResource]) UIManager.put(key, font) } I used the code above to change all the default fonts in Scala Swing ...

Running Eclipse Scala Plugin with previous version of Scala

The scala plugin seems to automatically download version 2.8 of Scala. I'l like to try out the Gridgain 3.0-beta, which currently only works with Scala 2.7.7. Since Gridgain 3.0-beta already provides scala-compiler-2.7.7.jar and scala-library-2.7.7.jar, is it possible to get the Eclipse Scala Plugin to compile to Scala 2.7.7? I tried ...

Having trouble converted a scala case class to json JObject when it contains an field of type Enumeration

In Scala 2.8 and liftweb.net 2.0 I'm trying to serialize a case-class to Json but when the case class has an enumeration in it it fails. import net.liftweb.json.DefaultFormats import net.liftweb.json.Extraction._ import net.liftweb.json.JsonDSL._ import net.liftweb.json.JsonAST.JObject // Enumerated type object ColorType extends scal...

How to cast Scala value already defined in the function

Hi, how to convert a value when using it? Example: scala> def sum(x:Double, y:Int) { | x + y | } sum: (x: Double,y: Int)Unit scala> println(sum(2,3)) () How to modify the line with println to print the correct number? Thanks ...

Creating Android apps without Java

I'd like to start creating Android apps but I don't like Java. I read that scala can be used to do it. Are there another option?(Clojure?) I'm a Python/Django developer so it would be great to learn a pretty different language. ...

Converting Types

I was trying to convert an object with Object type into FontUIResource type. In Java, it would be FontUIResource font = (FontUIResource)value How would I do that in Scala? ...

pattern match args and give error messages in a lightweight Scala script

I write a number of simple scala scripts that end up starting with a simple pattern match on args like: val Array(path, foo, whatever) = args // .. rest of the script uses "path", "foo", etc. Of course, if I supply the wrong number of arguments, I get an inscrutable error like: scala.MatchError: [Ljava.lang.String;@7786df0f at Ma...