question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nashorn script engine not found when running under sbt

See original GitHub issue

Hi, I have previously created an issue at Play project but it seems to be more sbt related. The issue is the following. I have just upgraded to Java 8 and I want to use Nashorn. Simply put, I have two projects, one scala lib and a play project to have a GUI.

I haven’t seen the issue straight away because the scala lib uses maven but when I try to load nashorn after running play with sbt -> run, the engine is not found and if I try to do it manually (new NashornScriptEngineFactory) I get a ClassDefNotFound.

I have created a very simple test from the basics scala project.

The code I have added is the following

"Nashorn" should "be available" in {
    import javax.script._
    val manager = new ScriptEngineManager()
    val engine = manager.getEngineByName("nashorn")
    engine should not be null
  }

For play, when I create a distribution and run it from outside sbt everything works and nashorn is found.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
montarocommented, Sep 15, 2014

I had the same problem with SBT project, and this worked for me

val engineManager: ScriptEngineManager = new ScriptEngineManager(null)
//Or
val engineManager: ScriptEngineManager = new ScriptEngineManager(getClass.getClassLoader)
0reactions
SethTisuecommented, Sep 8, 2015

re JSR 223, let’s discuss further at https://issues.scala-lang.org/browse/SI-8422

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scala Script Engine is not found when run in Test using Mill or ...
I have a strange behaviour concerning Testing Scala Script Engine. I have the following code: val manager = new ScriptEngineManager(getClass ...
Read more >
graalvm/graaljs - Gitter
Hi together, seems my code for interop between CompletableFuture and JS Promise fails on rc13 while it was executing fine on rc12. The...
Read more >
Why won't MATLAB find the java nashorn ScriptEngine?
First, let me make it clear that the nashorn engine is only available in java 1.8. I am using MATLAB R2015b and I...
Read more >
2 The Nashorn Java API
This chapter describes how to access Java from a script interpreted by the Nashorn engine.
Read more >
The importance of Scala.js
Programmers often ask me were Scala.js stands in the bigger picture, ... and at the time in 2017, I could not find a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found