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

98
Views
Want to run JavaScript code snippet which returns Boolean with the help of java

I want to run a JavaScript code snippet which returns boolean, from java.

Currently I am using ProcessBuilder to run the JavaScript program with the command jjs filename.

I am able to perform the operations and getting the output from getOutputStream properly.

But my requirement is to return boolean from the script, when I make the similar changes in the script it gives compile time error invalid return statement, which is obvious.

when I use

var a=5; var b=6; print(a+b);

I am getting a output 11. But I want to execute a script like

var a=5; 
if(a>0) 
    return true; 
else 
    return false;

I get errorStream like Invalid return statement Expected eof but found } } ^

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

0

The getInputStream method of the ProcessBuilder class gives you a stream from which you can read bytes. You have to convert the bytes to String and then parse to boolean.

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!