Configuring setenv.sh or setenv.bat

Configuration is done by adding a setting in the setenv.sh (for Linux) or setenv.bat (for Windows) in the <CATALINA_HOME>/bin/ folder. If the setenv.sh or setenv.bat file does not exist, you must create it.

 

Windows

Point out the Java installation to use.

Add the following lines:

set JAVA_HOME=JDK_home\[JDK folder]
set JRE_HOME= JDK_home\[JDK folder]

 

Set the UTF-8 character encoding.

Add the following line:

set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8

 

Enable Arrow Serialization.

With Java 17, this setting is necessary for loading Apache Arrow files and for using Arrow serialization with Python. Add the following line:

set JAVA_OPTS=%JAVA_OPTS% --add-opens java.base/java.nio=ALL-UNNAMED

Example

set JAVA_HOME=C:\Program Files\RedHat\java-17-openjdk-17.0.10.0.7-2
set JRE_HOME=C:\Program Files\RedHat\java-17-openjdk-17.0.10.0.7-2
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
set JAVA_OPTS=%JAVA_OPTS% --add-opens java.base/java.nio=ALL-UNNAMED

Finally, save the file setenv.bat.

For further details, see the Apache Tomcat 10 documentation.

 

Linux

Point out the Java installation to use.

Add the following lines:

JAVA_HOME=/path/to/jvm/version
JRE_HOME=/path/to/jvm/version

 

Set the UTF-8 character encoding.

Add the following line:

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"

 

Enable Arrow Serialization

With Java 17, this setting is necessary for loading Apache Arrow files and for using Arrow serialization with Python. Add the following line:

JAVA_OPTS="$JAVA_OPTS --add-opens java.base/java.nio=ALL-UNNAMED"

Example

JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
JAVA_OPTS="$JAVA_OPTS --add-opens java.base/java.nio=ALL-UNNAMED"

Finally, save the file setenv.sh.

For further details, see the Apache Tomcat 10 documentation.

 

NOTE:

If you don’t have the correct Java Options setting for Arrow, you will see the following error message when trying to load an Arrow file:”

Handler dispatch failed: java.lang.ExceptionInInitializerError

The Tomcat console will log:

java.lang.RuntimeException: Failed to initialize MemoryUtil. Was Java started with --add-opens=java.base/java.nio=ALL-UNNAMED? (See https://arrow.apache.org/docs/java/install.html)

<etc..>

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field long java.nio.Buffer.address accessible: module java.base does not "opens java.nio" to unnamed module @2322f814

 

 

 

(c) 2013-2024 Altair Engineering Inc. All Rights Reserved.

Intellectual Property Rights Notice | Technical Support