Calling an InDesign ExtendScript script from a Java application
Copy link to clipboard
Copied
Since ExtendScript / Javascript cannot access a database directly, I figured that I would use a Java program to do so, instead. However, I would need some data gathered from a rather large ExtendScript script that I've already written for InDesign.
Thus, is there any way to create a Java program that will launch InDesign CS6 (if it isn't already running), execute a specific script (.jsx file), then return a value (or values) back to the Java program when it's finished? I can then have the Java program plug that returned information into a MySQL database table. (I still need to look up how to do that last part, but I'm certain it's possible.)
Copy link to clipboard
Copied
The question is tagged with #mac - is that your platform? If so, have a look at javax.script - there is a ScriptEngine for AppleScript, and AppleScript can issue a DoScript event given a javascript. You'll then receive the results as string.
Dirk
Copy link to clipboard
Copied
Ah, I see. I need to write an AppleScript script as a sort of messenger that goes between the Java application and ExtendScript script in InDesign. I had to do something similar when I needed to have an InDesign script call Acrobat for a couple of tasks.
I have a lot more to learn about Java first, though, such as how to implement that package into Java, learning all of the new classes, properties, methods, etc. Java appears to be many orders of magnitude more complex and ExtendScript, since it's a full-blown programming language instead of just a scripting language. And I'm only just now (after six months) getting a halfway decent grasp of ExtendScript! :~/
Thanks for the help Dirk! :~)
Copy link to clipboard
Copied
Not only beginners are overwhelmed by the enormous Java libraries. Don't try the brute force attempt to catch up with the developments of decades, just learn the syntax, basic concepts and core packages. Choose a good IDE and tweak example programs until they break. You'll discover the other classes as you need them.
Btw, even though Steve Werner redirected you here, scripting questions are better posted to the scripting forum. This SDK forum is more about C++ plugins, and general Java programming fits neither. Maybe http://www.developer.com/java ? Top story of today there is an oldie from 2004, http://www.developer.com/java/data/article.php/3417381
Another good site is stackoverflow.com, for example http://stackoverflow.com/questions/11978407
Dirk
Copy link to clipboard
Copied
Thank you, Dirk. I'll check out those resources.

