Monday, December 24, 2012

Groovy Tips

Here are some productivity tips for Groovy development. Provided you have GROOVY_HOME/bin added to your path you can execute following commands:

  • running Groovy shell

Type 'help' or '\h' for help.
you can e.g. type: 
Sting.methods.each{println }

  • running graphic console


  • running uncompiled Grovy on web server
1. Add groovy.jar from $GROOVY_HOME/embedded to server classpath (WEB-INF/lib)

2. Add groovy.servlet.GroovyServlet to WEB-INF/web.xml.
3. Place your Groovy scripts wherever you'd normally place your JSP files.
4. Create hyperlinks to your Groovy scripts

  • automatic imports
Groovy automatically imports:import packages:

  • method pointers
In Groovy you can do the following:
def shoppingList = []
def add = shoppingList.&add
def remove = shoppingList.&remove
add "Milk"
add "Bread"
add "Beer"
remove "Beer"
add "Apple Juice"
print shoppingList

  • operators
The following are operators and corresponding methods:
a == b
a != b
a*b a.multiply(b)
a/b a.div(b)
a|b a.or(b)
a[b] = ca.putAt(b,c)
a << b a.leftShift(b)
a >> ba.rightShift(b)
a < b
a > b
a <= b
a >= b

Thursday, November 1, 2012

All these new fancy web pages..

As a Java developer with long time experience I always found touching web pages a tiresome task. Messing up with all the HTML and JavaScript code, digging into CSS to make JSP render as expected was not an obvious thing. Still it is not. This is mainly because I never had enough time to understand CSS and JavaScript and I admit it was never priority number 1 knowing each web browser have its own specificity  I just thought it' snot worth of trying. Better concentrate at Java word where most of the things is standardized and behaves as expected.

This was until I started to work closely with SmartClient and Grails.
Working closer with SmartClient library opened my eyes how much JavaScript evolved over the last years, how rapidly it develops and how amazing possibility it gives in comparison to what I met in legacy software in which it was just a little addition to all HTML rendered on server side. Now JavaScript is the place where all moves, flickers and rocks while server side is doing some business calculations not caring at all about front-end. It just takes data and returns data in desired format like JSON for instance.

Seeing a great potential in JavaScript I decided to learn more about it. By change there was a training organized in Poznan, Poland titled 'JavaScritp for Java Developers'. Wow, I thought  this is exactly what I need, so I subscribed and I was not mistaken. The 2-days training gave me a feel of how to write modern JavaScript pages using technologies like BackboneJs, RequireJs, UnderscodeJs. I even learned there are unit tests written for it using libraries analogical to JUnit in Java word. It looks all this new JavaScript is not that far from ideas I know from Java world.

Still not sure if this is me who found JavaScript or JavaScipt found me, but today I came into another blog post that gave me a kick to learn more in this field.
Article written in Polish can be found at and author's blog is here, also quite interesting.
The author is pointing out many interesting tools used in modern web development.
I hope to give them a try so I set up a project on github where I plan to gather some demo code of my trials with it. For now there are some web scaling example with CSS available.

I also found good designer's resources at
Some free e-books can be downloaded from here but I've downloaded the pdf and copied it to my github.

Saturday, September 1, 2012

My first meeting with Closure

I got inspired by video of life music hacking jam session
so that I wanted to try Overtone project myself.
First you need to install Lein which is a kind of depency managet for Clojure.
You can follow with instructions at
What I did on Windows was downloading lein.bat from and stand-alone jar from
Then I had to set env. variable LEIN_HOME to my local dir, e.g.: c:/tools/lein and put the stand-alone jar in
and add LEIN_HOME to PATH system variable so that lein.bat could be found globally in system.

Then when I typed
in system console it downloaded missing Clojure dependencies and welcomed me with message:

Leiningen is a tool for working with Clojure projects.
Several tasks are available:
check               Check syntax and warn on reflection.
classpath           Write the classpath of the current project to output-file.
clean               Remove all files from project's target-path.
compile             Compile Clojure source into .class files.
deploy              Build jar and deploy to remote repository.
deps                Show details about dependencies.
do                  Higher-order task to perform other tasks in succession.
help                Display a list of tasks or help for a given task.
install             Install current project to the local repository.
jar                 Package up all the project's files into a jar file.
javac               Compile Java source files.
new                 Generate project scaffolding based on a template.
plugin              DEPRECATED. Please use the :user profile instead.
pom                 Write a pom.xml file to disk for Maven interoperability.
repl                Start a repl session either with the current project or standalone.
retest              Run only the test namespaces which failed last time around.
run                 Run the project's -main function.
search              Search remote maven repositories for matching jars.
show-profiles       List all available profiles or display one if given an argument.
test                Run the project's tests.
trampoline          Run a task without nesting the project's JVM inside Leiningen's.
uberjar             Package up the project files and all dependencies into a jar file.
upgrade             Upgrade Leiningen to specified version or latest stable.
version             Print version for Leiningen and the current JVM.
with-profile        Apply the given task with the profile(s) specified.
Run lein help $TASK for details.
See also: readme, faq, tutorial, news, sample, profiles,
deploying and copying.

Now I can start playing with Overtone...
Then you download sources from github:

git clone git://

and build project with

lein deps

Now launch REPL and follow according to steps at Overtone github:

The quickest way to get started is to launch a clojure repl using lein. In the overtone project directory....
$ lein repl
Then make some noise :)
user> (use '
   ...wait a bit...
user> (demo (sin-osc))
For a better experience try Overtone in emacs or Overtone in vim.
Unfortunately that ain't that easy and first command: (use 'overtone.livebrought me to error message:
--> Loading Overtone...
UnsatisfiedLinkError Unable to load library 'scsynth': Nie mo┐na odnalečŠ okreťlonego modu│u.
  com.sun.jna.NativeLibrary.loadLibrary (
I wish you were more lucky, I will come back to resolve it in a while..stay tuned...

Soo.. after a while I'm back with a different approach.
I followed the following steps:
From command line execute:
lein new tutorial
cd tutorial 

edit project.clj generated in folder tutorial and add dependency:

(defproject tutorial "1.0"
  :dependencies [ [org.clojure/clojure "1.3.0"]
                  [overtone "0.7.1"] ])

Then type:
lein deps
Install SuperCollider ( - during installation enter installation folder name as SuperCollider, without version number. I'm not sure if otherwise Overtune will locate scsynth.exe correctly.

Start REPL (

lein repl
Type commands:

(use 'overtone.core)

and start playing... (

Saturday, May 5, 2012

JSON editor for Eclipse

Simple and handful editor from , however installation was not that obvious. 'Install from zip file' did not work for me. It was sufficient to unzip content and copy 'plugins' and 'features' content to 'plugins' and 'features' folders in eclipse installation. Works for me :) Checked on Eclipse Inigo and Spring Source Tools Suite.

Sunday, January 15, 2012

EL not evaluated in JSP

I've spent almost an hour do discover why Expression Language entries like:


are not evaluated on JSP pages.

The thing was version in web.xml file.
By default my eclipse generated

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"" >



Changing to

<web-app xmlns=""


made it work.

Make sure you have also in your server classpath 2 jar files:

jstl.jar - JSTL implementation classes
standard.jar - Standard Taglib JSTL implementation classes

More reference in this  thread.