How to work with Scala and Jcurses?

382 views Asked by At

I want to use Jcurses with Scala on a 64-bit Ubuntu. Unfortunately i didn't find any tutorial about this subject. Can anybody help me!

My test program "testjcurses.scala"

import jcurses.system._
object TestJcurses {
  def main(args:Array[String]) {
    println("okay")
    Toolkit.init()
    }
  }

I processed it the following way:

fsc -cp ~/software/Java/jcurses/lib/jcurses.jar:~/software/Java/jcurses/src -d . -Djava.library.path=~/software/Java/jcurses/lib testjcurses.scala 
scala -cp ~/software/Java/jcurses/lib/jcurses.jar:~/software/Java/jcurses/src:.  -Djava.library.path=~/software/Java/jcurses/lib  TestJcurses

The result is:

okay
java.lang.NullPointerException
    at jcurses.system.Toolkit.getLibraryPath(Toolkit.java:97)
    at jcurses.system.Toolkit.<clinit>(Toolkit.java:37)
    at TestJcurses$.main(testjcurses.scala:9)
    at TestJcurses.main(testjcurses.scala)
   ..........

Can anybody help me?

1

There are 1 answers

0
Blaisorblade On BEST ANSWER

Unfortunately you can't use ~ in bash like that — ~ is expanded to your home dir only right after an (unquoted) space (technically, at the beginning of a bash word, but "after a space" is the simple version). Look how your command line is expanded:

$ echo scala -cp ~/software/Java/jcurses/lib/jcurses.jar:~/software/Java/jcurses/src:.  -Djava.library.path=~/software/Java/jcurses/lib  TestJcurses
scala -cp /Users/pgiarrusso/software/Java/jcurses/lib/jcurses.jar:~/software/Java/jcurses/src:. -Djava.library.path=~/software/Java/jcurses/lib TestJcurses

As you can see, the ~ is there in the expanded version, and will arrive unchanged to your program, which will be unable to interpret it as anything since tilde expansion is a job for the shell.

Also, you shouldn't need the source directory ~/software/Java/jcurses/src in your classpath (since source files aren't needed to run the program). So try:

scala -cp ~/software/Java/jcurses/lib/jcurses.jar:. -Djava.library.path=$HOME/software/Java/jcurses/lib  TestJcurses