• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Executing Faker.js in Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys!

I have a small problem with execution of js code in Java.
My goal is to use this js faker API https://github.com/marak/Faker.js/ and call its methods in Java.



If I use the code above, it will crash on:
javax.script.ScriptException: TypeError: Cannot set property "faker" of undefined in src/com/test/faker/faker.js at line number 1

I think this shouldn't be a problem on my side, but with that js faker code which cannot be loaded properly in java script engine.
Can anyone give me a hint what is causing this error and how to fix it?

PS: as you can see, I'm not a good friend with js
 
Saloon Keeper
Posts: 7411
170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I took a quick look around Github, but didn't see a script "faker.js". Can you provide a direct link? It's hard to even speculate what might be going on without seeing the actual JS code.
 
Marshal
Posts: 76392
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:I took a quick look around Github, but didn't see a script "faker.js". Can you provide a direct link? It's hard to even speculate what might be going on without seeing the actual JS code.



Direct link to faker.js
 
Tim Moores
Saloon Keeper
Posts: 7411
170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a big file! I think my first advice would be to try it with a much smaller version (maybe 10% in size), and thus to make sure the failure isn't caused by the file size.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd break up that first line.
It's a monster.
 
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic