Okay finally i got trough it and so I'm answering my own question.
Ntsh's idea of using ScriptEngine (see question's comments) was nice and worked nice in java, but since it's not part of android by default, I had to import the jar. Even that the code compiles, it just doesn't seem to work on some devices (i got it working only in my 4.2 Genymotion VM).
So I searched for another approach and decided to use webview to run javascrip. This seems to be a bad solution, but it works:
First I made a php file on server, that takes js file, adds some html and javascript code around it, to make it valid html and to make json out of this js array and prints it.
On android I just open this url in hidden webview and once page is loaded, I take it's source and extract relevant data, to parse it from json to java. This post was very helpful for that.
However, this approach has some disadvantages:
- it cannot be run in background (using backgound services and broadcast recievers for example), since webview is a gui element
- it has a security whole, because ANY js file that gets loaded into webview can call the function (now called only when page is loaded) at ANY time. This is how it can inject some other text and so on...
So if anyone has a better solution please let me know.