Search code examples
javajava-8nashorn

Apparently java doesn't have the same nashorn.jar for Linux and Windows


I'm trying to configure my workspace from windows in linux.

This code which is OK in windows:

jdk.nashorn.internal.parser.JSONParser p = new jdk.nashorn.internal.parser.JSONParser(s, null);

gets the following error under linux:

constructor JSONParser in class JSONParser cannot be applied to different types

And when I look at the source code under Linux and at the source code under Windows, I see very clear that the same class is different.

Does anyone know why this? If so, WORA principle isn't applied here, which seems pretty confusing to me.


Solution

  • With the hints given by different users, especially @FedericoklezCulloca, I managed to fix my problem. I would state the following points bellow:

    1. Use only "exposed" interface from Java API and avoid using restricted one.
    2. I had to get exactly the same version of JDK (the same vendor, of course) in linux. Than it worked.