Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT gives java.lang.NullPointerException when trying to run simple "Hello!" example script

I'm trying my hand at Scala for the first time, and I've chosen to do so using SBT 0.13.9 on a Linux machine running a new install of Ubuntu 14.04LTS.

I've been following the instructions given on the SBT website to the letter, and I'm now trying to run the "Hello!" example script, which is as follows:

object Hi {
  def main(args: Array[String]) = println("Hi!")
}

When I try to run, I get the following output:

[trace] Stack trace suppressed: run last compile:compileIncremental for the full output.
[error] (compile:compileIncremental) java.lang.NullPointerException
[error] Total time: 1 s, completed 22 Aug 2015, 2:30:09 PM

Being completely new to Scala and SBT (and also relatively new to Linux) I'm sure I've just overlooked something obvious. No amount of Googling has yielded any answers so far though.

What should I check first? I'd really appreciate any advice anyone can offer.

like image 577
Gareth Jones Avatar asked Aug 22 '15 04:08

Gareth Jones


1 Answers

I had the same error, on exactly the same code snippet! ie the first one in the scala sbt getting started hello.html

My problem was resolved when i uninstalled the java 9 sdk and installed the java 8 sdk.

Doing this required that i also had to then re-install scala and sbt.

These I installed with the instructions from HERE but replacing the version numbers in the commands with scala-2.11.7.deb and sbt-0.13.9.deb (my dev machine being on ubuntu 14.04)

like image 162
Simon Dowdeswell Avatar answered Oct 14 '22 22:10

Simon Dowdeswell