Share scripts between processes

Hi,

I would like to share some scripts between different process without duplicate to much code, so currently I using a scriptTask like this (inspiring by an other post on the forum) :

 var resourceURL = new     java.net.URL("http://localhost:8080/folder/my_script.js");
 var urlConnection = resourceURL.openConnection();
 var inputStream = new java.io.InputStreamReader(urlConnection.getInputStream());
 var bufferedReader = new java.io.BufferedReader(inputStream);
 var inputLine;
 var text = "";
 while ((inputLine = bufferedReader.readLine()) != null) {
      text += inputLine
 }
 bufferedReader.close();
 eval(text);

however, it’s only works with javascript and using eval() seems bad.

So I would like to know if someone knows a better solution to run my scripts

thanks for reading,
Romain.

You can use the nashorn load() function to load scripts from urls:

https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions

yes thanks for the answer and thanks for the website.

It’s gonna be really usefull. I didn’t find which functions I can use.