Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  67] [ 4]  / answers: 1 / hits: 23705  / 16 Years ago, mon, march 16, 2009, 12:00:00

In JDK6, is there a way to load multiple scripts, each in a file, and have the one script reference a method of another script? Sort of like include?


More From » java

 Answers
10

I think you're after the load() method/property of Rhino's global object/scope



load(file1.js);
load(file2.js);
load(file3.js);

methodFromFileOne();
var bar = methodFromFileTwo();
var etc = dotDotDot();


This will load a javascript source file, similar to how include/require will in PHP. Once you load a file, you'll be able to call and function or use any object defined in the loaded file.



This is how things work when you're using the Rhino shell, which is the only context I know (your question mentioned the Java SDK, which is outside my area of experience)


[#99838] Wednesday, March 11, 2009, 16 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breonnamayah

Total Points: 574
Total Questions: 115
Total Answers: 96

Location: England
Member since Sun, May 21, 2023
1 Year ago
breonnamayah questions
;