getCurrentServer returns null on QuPath-0.2.3 (console).exe


I am running QuPath-0.2.3 (console).exe with a script argument:

"C:\Program Files\QuPath-0.2.3\QuPath-0.2.3 (console).exe" --image "D:/QMDownload/9/test4/PyramidalCell_Z000.tif" script "C:\\Users\\rmd\\AppData\\Local\\Temp\\tp8347b50c.groovy"

The content of the script is:

server = getCurrentServer();
int H = server.getHeight();

The error is:

9:50:31.173 [main] [INFO ] qupath.ScriptCommand - Setting tile cache size to 1012.50 MB (25.0% max memory) 
19:50:31.754 [main] [INFO ] qupath.lib.scripting.QP - Initializing type adapters 
======welcome to slide2ims. Now begin importing ===== 
======finished importing ===== 
NullPointerException at line 0: Cannot invoke method getHeight() on null object

When I run this script in QuPath GUI, there is no problem. Does the command to get server not work in headless/console mode?


You have to specify the script first. See the tip in the docs:

which links to this post:

Solved by put Script in first argument. Thank you!

"C:\Program Files\QuPath-0.2.3\QuPath-0.2.3 (console).exe" script "C:\\Users\\rmd\\AppData\\Local\\Temp\\tp8347b50c.groovy" --image "D:/QMDownload/9/test4/PyramidalCell_Z000.tif"

1 Like