Setting environment variable TESSDATA_PREFIX in To

2019-04-02 01:18发布

问题:

We are using Tesseract OCR Java library called Tess4J. It works fine if run as a standalone application. It needs a variable called TESSDATA_PREFIX which contains the tessdata config and other charset related files.

It also runs fine with embedded Tomcat 6 server in eclipse. I had set TESSDATA_PREFIX as an environment variable by using the launch configuration.

But when I package everything into a WAR and drop it in deploy directory of tomcat, the environment variable does not seem to be picked and the server crashes the moment it encounters the doOCR api( which needs the tessdata config).

I tried setting this env variable inside catalina.bat and also thru command line, but no luck.

回答1:

Environment variables in Tomcat should be put into a setenv.bat/setenv.sh script in the bin directory.