Java + Ghostscript

Hi!

I’m trying to run a java aplication which uses http://www.ghost4j.org/ (which uses ghostscript)

I installed ghostscript via nix-env -iA nixos.ghostscript

The application fails to invoke the gs binary with the following error:

java.lang.UnsatisfiedLinkError: Unable to load library 'gs': Native library (linux-x86-64/libgs.so) not found in resource path (/nix/store/jqi9jsizka3zm6cc70smgl3dnhansar8-idea-ultimate-2019.3.2/idea-ultimate-2019.3.2/lib/idea_rt.jar:/nix/store/jqi9jsizka3zm6cc70smgl3dnhansar8-idea-ultimate-2019.3.2/idea-ultimate-2019.3.2/plugins/junit/lib/junit5-rt.jar:/nix/store/jqi9jsizka3zm6cc70smgl3dnhansar8-idea-ultimate-2019.3.2/idea-ultimate-2019.3.2/plugins/junit/lib/junit-rt.jar:/home/jean/mouts/porto-itapoa/ocr/target/test-classes:/home/jean/mouts/porto-itapoa/ocr/target/classes:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.4.RELEASE/spring-boot-starter-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot/2.1.4.RELEASE/spring-boot-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/springframework/spring-context/5.1.6.RELEASE/spring-context-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.4.RELEASE/spring-boot-autoconfigure-2.1.4.RELEASE.jar:/home/jean/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/home/jean/.m2/repository/org/springframework/spring-core/5.1.6.RELEASE/spring-core-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/spring-jcl/5.1.6.RELEASE/spring-jcl-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter-test/2.1.4.RELEASE/spring-boot-starter-test-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-test/2.1.4.RELEASE/spring-boot-test-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-test-autoconfigure/2.1.4.RELEASE/spring-boot-test-autoconfigure-2.1.4.RELEASE.jar:/home/jean/.m2/repository/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/home/jean/.m2/repository/net/minidev/json-smart/2.3/json-smart-2.3.jar:/home/jean/.m2/repository/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/home/jean/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/jean/.m2/repository/org/assertj/assertj-core/3.11.1/assertj-core-3.11.1.jar:/home/jean/.m2/repository/org/mockito/mockito-core/2.23.4/mockito-core-2.23.4.jar:/home/jean/.m2/repository/net/bytebuddy/byte-buddy/1.9.12/byte-buddy-1.9.12.jar:/home/jean/.m2/repository/net/bytebuddy/byte-buddy-agent/1.9.12/byte-buddy-agent-1.9.12.jar:/home/jean/.m2/repository/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/home/jean/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/jean/.m2/repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/home/jean/.m2/repository/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/home/jean/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/home/jean/.m2/repository/org/springframework/spring-test/5.1.6.RELEASE/spring-test-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/xmlunit/xmlunit-core/2.6.2/xmlunit-core-2.6.2.jar:/home/jean/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/home/jean/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.4.RELEASE/spring-boot-starter-web-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.4.RELEASE/spring-boot-starter-json-2.1.4.RELEASE.jar:/home/jean/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8.jar:/home/jean/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.8/jackson-datatype-jdk8-2.9.8.jar:/home/jean/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.8/jackson-datatype-jsr310-2.9.8.jar:/home/jean/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.8/jackson-module-parameter-names-2.9.8.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.4.RELEASE/spring-boot-starter-tomcat-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.17/tomcat-embed-core-9.0.17.jar:/home/jean/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.17/tomcat-embed-el-9.0.17.jar:/home/jean/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.17/tomcat-embed-websocket-9.0.17.jar:/home/jean/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.16.Final/hibernate-validator-6.0.16.Final.jar:/home/jean/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/home/jean/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/home/jean/.m2/repository/org/springframework/spring-web/5.1.6.RELEASE/spring-web-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/spring-beans/5.1.6.RELEASE/spring-beans-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/spring-webmvc/5.1.6.RELEASE/spring-webmvc-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/spring-aop/5.1.6.RELEASE/spring-aop-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/spring-expression/5.1.6.RELEASE/spring-expression-5.1.6.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter-log4j2/2.1.4.RELEASE/spring-boot-starter-log4j2-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.jar:/home/jean/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/home/jean/.m2/repository/org/apache/logging/log4j/log4j-core/2.11.2/log4j-core-2.11.2.jar:/home/jean/.m2/repository/org/apache/logging/log4j/log4j-jul/2.11.2/log4j-jul-2.11.2.jar:/home/jean/.m2/repository/org/slf4j/jul-to-slf4j/1.7.26/jul-to-slf4j-1.7.26.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-configuration-processor/2.1.4.RELEASE/spring-boot-configuration-processor-2.1.4.RELEASE.jar:/home/jean/.m2/repository/io/springfox/springfox-swagger-ui/2.9.2/springfox-swagger-ui-2.9.2.jar:/home/jean/.m2/repository/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar:/home/jean/.m2/repository/io/springfox/springfox-swagger2/2.9.2/springfox-swagger2-2.9.2.jar:/home/jean/.m2/repository/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/home/jean/.m2/repository/io/swagger/swagger-models/1.5.20/swagger-models-1.5.20.jar:/home/jean/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/home/jean/.m2/repository/io/springfox/springfox-spi/2.9.2/springfox-spi-2.9.2.jar:/home/jean/.m2/repository/io/springfox/springfox-core/2.9.2/springfox-core-2.9.2.jar:/home/jean/.m2/repository/io/springfox/springfox-schema/2.9.2/springfox-schema-2.9.2.jar:/home/jean/.m2/repository/io/springfox/springfox-swagger-common/2.9.2/springfox-swagger-common-2.9.2.jar:/home/jean/.m2/repository/com/google/guava/guava/20.0/guava-20.0.jar:/home/jean/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/home/jean/.m2/repository/org/slf4j/slf4j-api/1.7.26/slf4j-api-1.7.26.jar:/home/jean/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar:/home/jean/.m2/repository/org/mapstruct/mapstruct/1.2.0.Final/mapstruct-1.2.0.Final.jar:/home/jean/.m2/repository/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2.jar:/home/jean/.m2/repository/org/projectlombok/lombok/1.18.6/lombok-1.18.6.jar:/home/jean/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar:/home/jean/.m2/repository/net/sourceforge/tess4j/tess4j/4.5.1/tess4j-4.5.1.jar:/home/jean/.m2/repository/com/github/jai-imageio/jai-imageio-core/1.4.0/jai-imageio-core-1.4.0.jar:/home/jean/.m2/repository/org/apache/pdfbox/pdfbox/2.0.18/pdfbox-2.0.18.jar:/home/jean/.m2/repository/org/apache/pdfbox/fontbox/2.0.18/fontbox-2.0.18.jar:/home/jean/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/home/jean/.m2/repository/org/apache/pdfbox/pdfbox-tools/2.0.18/pdfbox-tools-2.0.18.jar:/home/jean/.m2/repository/org/apache/pdfbox/pdfbox-debugger/2.0.18/pdfbox-debugger-2.0.18.jar:/home/jean/.m2/repository/org/apache/pdfbox/jbig2-imageio/3.0.3/jbig2-imageio-3.0.3.jar:/home/jean/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar:/home/jean/.m2/repository/net/sourceforge/lept4j/lept4j/1.13.0/lept4j-1.13.0.jar:/home/jean/.m2/repository/org/jboss/jboss-vfs/3.2.15.Final/jboss-vfs-3.2.15.Final.jar:/home/jean/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.26/jcl-over-slf4j-1.7.26.jar:/home/jean/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.26/log4j-over-slf4j-1.7.26.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-eureka-client/2.1.0.RELEASE/spring-cloud-starter-netflix-eureka-client-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-starter/2.1.0.RELEASE/spring-cloud-starter-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-context/2.1.0.RELEASE/spring-cloud-context-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/security/spring-security-rsa/1.0.7.RELEASE/spring-security-rsa-1.0.7.RELEASE.jar:/home/jean/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.60/bcpkix-jdk15on-1.60.jar:/home/jean/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.60/bcprov-jdk15on-1.60.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-netflix-hystrix/2.1.0.RELEASE/spring-cloud-netflix-hystrix-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.1.4.RELEASE/spring-boot-starter-aop-2.1.4.RELEASE.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-netflix-eureka-client/2.1.0.RELEASE/spring-cloud-netflix-eureka-client-2.1.0.RELEASE.jar:/home/jean/.m2/repository/com/netflix/eureka/eureka-client/1.9.8/eureka-client-1.9.8.jar:/home/jean/.m2/repository/org/codehaus/jettison/jettison/1.3.7/jettison-1.3.7.jar:/home/jean/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar:/home/jean/.m2/repository/com/netflix/netflix-commons/netflix-eventbus/0.3.0/netflix-eventbus-0.3.0.jar:/home/jean/.m2/repository/com/netflix/netflix-commons/netflix-infix/0.3.0/netflix-infix-0.3.0.jar:/home/jean/.m2/repository/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar:/home/jean/.m2/repository/joda-time/joda-time/2.10.1/joda-time-2.10.1.jar:/home/jean/.m2/repository/org/antlr/antlr-runtime/3.4/antlr-runtime-3.4.jar:/home/jean/.m2/repository/org/antlr/stringtemplate/3.2.1/stringtemplate-3.2.1.jar:/home/jean/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/home/jean/.m2/repository/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar:/home/jean/.m2/repository/org/apache/commons/commons-math/2.2/commons-math-2.2.jar:/home/jean/.m2/repository/com/netflix/archaius/archaius-core/0.7.6/archaius-core-0.7.6.jar:/home/jean/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar:/home/jean/.m2/repository/com/netflix/servo/servo-core/0.12.21/servo-core-0.12.21.jar:/home/jean/.m2/repository/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar:/home/jean/.m2/repository/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar:/home/jean/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar:/home/jean/.m2/repository/org/apache/httpcomponents/httpclient/4.5.8/httpclient-4.5.8.jar:/home/jean/.m2/repository/org/apache/httpcomponents/httpcore/4.4.11/httpcore-4.4.11.jar:/home/jean/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/home/jean/.m2/repository/com/google/inject/guice/4.1.0/guice-4.1.0.jar:/home/jean/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/jean/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/jean/.m2/repository/com/github/vlsi/compactmap/compactmap/1.2.1/compactmap-1.2.1.jar:/home/jean/.m2/repository/com/github/andrewoma/dexx/dexx-collections/0.2/dexx-collections-0.2.jar:/home/jean/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.8/jackson-core-2.9.8.jar:/home/jean/.m2/repository/com/netflix/eureka/eureka-core/1.9.8/eureka-core-1.9.8.jar:/home/jean/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar:/home/jean/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar:/home/jean/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-archaius/2.1.0.RELEASE/spring-cloud-starter-netflix-archaius-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-netflix-archaius/2.1.0.RELEASE/spring-cloud-netflix-archaius-2.1.0.RELEASE.jar:/home/jean/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar:/home/jean/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-ribbon/2.1.0.RELEASE/spring-cloud-starter-netflix-ribbon-2.1.0.RELEASE.jar:/home/jean/.m2/repository/com/netflix/ribbon/ribbon/2.3.0/ribbon-2.3.0.jar:/home/jean/.m2/repository/com/netflix/ribbon/ribbon-transport/2.3.0/ribbon-transport-2.3.0.jar:/home/jean/.m2/repository/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar:/home/jean/.m2/repository/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar:/home/jean/.m2/repository/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar:/home/jean/.m2/repository/com/netflix/ribbon/ribbon-core/2.3.0/ribbon-core-2.3.0.jar:/home/jean/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.3.0/ribbon-httpclient-2.3.0.jar:/home/jean/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.3.0/netflix-commons-util-0.3.0.jar:/home/jean/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.3.0/ribbon-loadbalancer-2.3.0.jar:/home/jean/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar:/home/jean/.m2/repository/io/reactivex/rxjava/1.3.8/rxjava-1.3.8.jar:/home/jean/.m2/repository/com/netflix/ribbon/ribbon-eureka/2.3.0/ribbon-eureka-2.3.0.jar:/home/jean/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar:/home/jean/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar:/home/jean/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-hystrix/2.1.0.RELEASE/spring-cloud-starter-netflix-hystrix-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-netflix-ribbon/2.1.0.RELEASE/spring-cloud-netflix-ribbon-2.1.0.RELEASE.jar:/home/jean/.m2/repository/com/netflix/hystrix/hystrix-core/1.5.18/hystrix-core-1.5.18.jar:/home/jean/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar:/home/jean/.m2/repository/com/netflix/hystrix/hystrix-serialization/1.5.18/hystrix-serialization-1.5.18.jar:/home/jean/.m2/repository/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.8/jackson-module-afterburner-2.9.8.jar:/home/jean/.m2/repository/com/netflix/hystrix/hystrix-metrics-event-stream/1.5.18/hystrix-metrics-event-stream-1.5.18.jar:/home/jean/.m2/repository/com/netflix/hystrix/hystrix-javanica/1.5.18/hystrix-javanica-1.5.18.jar:/home/jean/.m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/home/jean/.m2/repository/org/aspectj/aspectjweaver/1.9.2/aspectjweaver-1.9.2.jar:/home/jean/.m2/repository/io/reactivex/rxjava-reactive-streams/1.2.1/rxjava-reactive-streams-1.2.1.jar:/home/jean/.m2/repository/org/reactivestreams/reactive-streams/1.0.2/reactive-streams-1.0.2.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-starter-openfeign/2.1.0.RELEASE/spring-cloud-starter-openfeign-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-openfeign-core/2.1.0.RELEASE/spring-cloud-openfeign-core-2.1.0.RELEASE.jar:/home/jean/.m2/repository/io/github/openfeign/form/feign-form-spring/3.5.0/feign-form-spring-3.5.0.jar:/home/jean/.m2/repository/io/github/openfeign/form/feign-form/3.5.0/feign-form-3.5.0.jar:/home/jean/.m2/repository/commons-fileupload/commons-fileupload/1.3.3/commons-fileupload-1.3.3.jar:/home/jean/.m2/repository/org/springframework/cloud/spring-cloud-commons/2.1.0.RELEASE/spring-cloud-commons-2.1.0.RELEASE.jar:/home/jean/.m2/repository/org/springframework/security/spring-security-crypto/5.1.5.RELEASE/spring-security-crypto-5.1.5.RELEASE.jar:/home/jean/.m2/repository/io/github/openfeign/feign-core/10.1.0/feign-core-10.1.0.jar:/home/jean/.m2/repository/io/github/openfeign/feign-slf4j/10.1.0/feign-slf4j-10.1.0.jar:/home/jean/.m2/repository/io/github/openfeign/feign-hystrix/10.1.0/feign-hystrix-10.1.0.jar:/home/jean/.m2/repository/org/ghost4j/ghost4j/1.0.1/ghost4j-1.0.1.jar:/home/jean/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/home/jean/.m2/repository/commons-beanutils/commons-beanutils/1.9.2/commons-beanutils-1.9.2.jar:/home/jean/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/jean/.m2/repository/org/apache/xmlgraphics/xmlgraphics-commons/1.4/xmlgraphics-commons-1.4.jar:/home/jean/.m2/repository/com/lowagie/itext/2.1.7/itext-2.1.7.jar:/home/jean/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar)

any suggestions are welcome!

Edit:
My guess is that ghostscript package is not in the ENV path for my IDE/application, if thats the case, what would be the proper way of adding it?

So, I was able to solve my problem, the following steps did it for me, will document it here just in case someone happen to have the same problem!

I learned about an env. variable: LD_LIBRARY_PATH here, so I set up my configuration.nix as follows (only showing the relevant parts):

environment = {
  systemPackages = with pkgs; [
    # other packages
    ghostscript
  ];
  variables = {
    LD_LIBRARY_PATH = "${pkgs.ghostscript}/lib"; 
  };
};

I don’t think this this is the proper way to solve this issue, but it’s working!
Maybe that’s related to the way Java JNA tries to load the libraries?

any suggestions/comments are welcome!

does whereis libgs.so.9 finds a path in your setup?