Executing groovy scripts in headless mode

Hi Jim!

Thank you very much for your quick reply! Your example works! Great!
It might also be a good idea to add this workaround in the documentation.
For example here: http://www.jalview.org/help/html/features/groovy.html

Thanks again!

Leonhard

···

On 14.07.2015 13:47, Jim Procter wrote:

Hi Leonhard - thanks for emailing !
The secret to headless mode is that Jalview.getAlignment() doesn't work
in the GUI mode.. yet (See http://issues.jalview.org/browse/JAL-1812).

Instead, use currentAlFrame - this Hello World example will work.

print "Hello World.\n";
print
currentAlFrame.getViewport().getAlignment().getSequenceAt(1).getName()

See below for the kind of output on the command line that you would see:

% java -classpath classes -Djava.ext.dirs=lib jalview.bin.Jalview
-headless -groovy STDIN -open examples/uniref50.fa
Java version: 1.8.0_45
x86_64 Mac OS X 10.10.3
Error reading author details: java.io.FileNotFoundException:
/Users/jprocter/git/jalview/classes (Is a directory)
Error reading build details: java.io.FileNotFoundException:
/Users/jprocter/git/jalview/classes (Is a directory)
Jalview Version: Test
CMD [-open examples/uniref50.fa] executed successfully!
Jul 14, 2015 12:13:19 PM jalview.util.MessageManager <clinit>
INFO: Getting messages for lang: en_US
java.awt.HeadlessException
Executing script STDIN
print "Hello World.\n";
print
currentAlFrame.getViewport().getAlignment().getSequenceAt(1).getName()
Hello World.
FER_CAPANCMD groovy[STDIN] executed successfully!

Hope that works ! Let me know how you get on..
Jim