Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Use import in javascript being called from Java program through graalvm

I am trying out Graalvm for a use case and I was wondering if I can use import statements in the javascript being called from java. I have tried both:

context.eval("js", "import v4 from 'uuid';var o = v4();");

which gives the error Expected an operand but found import import v4 from 'uuid';var o = v4();

and

creating a separate script containing

import v4 from 'uuid';
var uu = v4();

then running the script via

InputStream inputStream = Controller.class.getResourceAsStream("/script.js");
String script = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
context.eval("js", script);

which returns the same error: Expected an operand but found import import v4 from 'uuid';

I went through the docs and it seems like it is possible. Can someone please guide me towards the correct approach?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!