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

232
Views
TypeError: Cannot call property getEncoder in object

I am trying to encode byte array using java package Base64 in a javascript. Javascript engine is Rhino.

Below is the error in logs.

java.util.concurrent.ExecutionException: javax.script.ScriptException: TypeError: Cannot call property getEncoder in object [JavaPackage java.util.Base64]. It is not a function, it is "object". 

Below is the snippet of code.

var md = java.security.MessageDigest.getInstance('SHA-256');
md.update(salt);
var sha256Bytes = []
sha256Bytes=md.digest(new java.lang.String(givenPassword).getBytes('UTF-8'));
var sha256Hash = java.lang.String(java.util.Base64.getEncoder().encode(sha256Bytes));

I am not able to figure out the issue here. Also, the package java.util.Base64.* is imported.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I imported class java.util.Base64$Encoder. Earlier I was importing it in java.util.Base64.Encoder . Not sure how $ makes a difference comparing to a '.' . But , I assume that my application imports static class in this way.

about 4 years ago · Juan Pablo Isaza Report
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!