java try-with-resource not working with scala : <p>In Scala application, am trying to read lines from a file using java nio try-with-resource construct.</p>

<p>Scala version 2.11.8<br>
Java version 1.8</p>

<pre><code>try(Stream&lt;String&gt; stream = Files.lines(Paths.get("somefile.txt"))){
    stream.forEach(System.out::println); // will do business process here
}catch (IOException e) {
    e.printStackTrace(); // will handle failure case here
}  
</code></pre>

<p>But the compiler throws error like<br>
◾not found: value stream<br>
◾A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.</p>

<p>Not sure what is the problem. Am new to using Java NIO, so any help is much appreciated.</p>
