Archive for the ‘scala’ Category


Speeding up Eclipse

January 25, 2011

Eclipse can get a bit sluggish, especially when you’ve got the Scala and Maven plugins installed into it. I found the following website with some useful improvements you can make to the eclipse.ini file to speed it up. This works for Windows and Linux systems and will probably work with Mac as well. It give eclipse more memory so if you are running a dev machine with 4GB of RAM then this should work fine. The eclipse.ini file can be found in the root of the eclipse application folder.

The vmargs parameter as shipped uses these heap settings (at the bottom of the eclispe.ini file):


It needs to specify a larger heap and more stack.


Adjust the max heap size (“mx”) to be sure that it fits in real memory. “ms” should be twice the “NewSize”.



Putting properties in the web xml file

January 25, 2011

If you are building a web app in Java or Scala, you might want to feed in a variable from outside which describes something special about the particular environment the web app is running on.  On a normal application you might do this from the command line with a command line argument.  In a web app, you put the variables in the web.xml file. In a maven built project this can be found in /src/main/java/webapp/WEB-INF/web.xml

The XML for the variable looks like this …


In your code, the property can be accessed by any class which extends HttpServlet. The following imports are therefore required:

import javax.servlet.http.HttpServlet;
import javax.naming.Context;
import javax.naming.InitialContext;

The property can then be accessed in your Java code like this:

Context env = (Context) (new InitialContext().lookup("java:comp/env"));
String PROPS_FOLDER = (String) env.lookup("PROPS_FOLDER");

And in Scala like this:

val env:Context = (new InitialContext().lookup("java:comp/env")).asInstanceOf[Context];
val PROPS_FOLDER:String = env.lookup("PROPS_FOLDER").asInstanceOf[String];