Example for Inkscape extension in Java?
Dear Inkscape devs, Can anyone point me to a working example of an Inkscape effect extension written in Java, running on Windows?
I've read the Script_extensions and INX_extension_descriptor_format wiki pages. I thought, theoretically I might just replace the command tag in the inx file with something like this: <command reldir="extensions" interpreter="java">Hello</command>
And then I could call a Hello World program like this one: class Hello { public static void main(String[] args) { for( String arg : args) System.err.println("Hello error: "+arg); }}
The program wouldn't return any document, but the error message would be displayed by Inkscape. However, when I test this, nothing gets displayed. When I change the program to write a file, that file doesn't appear either, so I guess the program isn't called. I can change the command text to any other value, but there is no notification that a script couldn't be found. I have written several Python extensions, but those hook up into the existing Inkscape Python extension framework, with inkex.py and everything. Maybe there's some hidden magic in there that I missed?
Can someone point me to a working Java example, or tell me what I did wrong here?
Many thanks in advance!Gerrit
Update: I tried Inkscape 0.47 instead of 0.48 now, and here an error message is briefly displayed in the console window (translated): Error: Main class C:\Users\USER\AppData\Local\Temp\ink_ext_XXXXXX.svgMEMVCW couldn't be found or loaded Does that ring a bell with anyone? Best regards,Gerrit
From: g99k@...19... To: inkscape-devel@lists.sourceforge.net Date: Fri, 13 Apr 2012 22:52:43 +0000 Subject: [Inkscape-devel] Example for Inkscape extension in Java?
Dear Inkscape devs,
Can anyone point me to a working example of an Inkscape effect extension written in Java, running on Windows?
I've read the Script_extensions and INX_extension_descriptor_format wiki pages. I thought, theoretically I might just replace the command tag in the inx file with something like this:
<command reldir="extensions" interpreter="java">Hello</command>
And then I could call a Hello World program like this one:
class Hello {> public static void main(String[] args) {
for( String arg : args)
System.err.println("Hello error: "+arg);
}
}>
The program wouldn't return any document, but the error message would be displayed by Inkscape. However, when I test this, nothing gets displayed. When I change the program to write a file, that file doesn't appear either, so I guess the program isn't called. I can change the command text to any other value, but there is no notification that a script couldn't be found.
I have written several Python extensions, but those hook up into the existing Inkscape Python extension framework, with inkex.py and everything. Maybe there's some hidden magic in there that I missed?
Can someone point me to a working Java example, or tell me what I did wrong here?
Many thanks in advance!> Gerrit>
What you propose seems completely reasonable to me. You will notice that some of the interpreters are listed explicitly in the following Inkscape source file. I don't remember if something has to be done here to make what you intend work properly.
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/src/exte... http://bazaar.launchpad.net/%7Einkscape.dev/inkscape/trunk/view/head:/src/extension/implementation/script.cpp
Update: I tried Inkscape 0.47 instead of 0.48 now, and here an error message is briefly displayed in the console window (translated):
Error: Main class C:\Users\USER\AppData\Local\Temp\ink_ext_XXXXXX.svgMEMVCW couldn't be found or loaded
Does that ring a bell with anyone?
To my eye that looks like java is successfully invoked, but the command line is inappropriate. Java is attempting to find your program inside of the temporary SVG file Inkscape created for you to process. I would recommend you do some additional investigation in to what command line Inkscape is using to invoke java.
Aaron Spike
participants (2)
-
Aaron Spike
-
Gerrit Karius