The steps below provide a solution for running the H2 Database console from a ZIP installation while ensuring it operates correctly as a user binary.
*1. Install H2 Database* Ensure you have extracted the H2 Database ZIP file to your desired location, e.g., /opt/h2/. *2. Create a Soft Link* Create a soft link to the H2 script for easy access: $ ln -s /opt/h2/bin/h2.sh /usr/local/bin/h2 *3. Modify the h2.sh Script* Edit the h2.sh script to ensure the correct directory is used regardless of how it's executed. Replace the content with the following: #!/bin/sh dir=$(dirname "$(readlink -f "$0")") # Changed from the original line java -cp "$dir/h2-2.3.232.jar:$H2DRIVERS:$CLASSPATH" org.h2.tools.Console "$@" *4. Test the Setup * You can now run the H2 Database console from anywhere in the terminal by simply typing: $ h2 *Explanation* The line *dir=$(dirname "$(readlink -f "$0")")* is added to resolve the absolute path of the script. This ensures that the script can locate the h2-2.3.232.jar file correctly, regardless of the current working directory or how the script is executed (e.g., via the soft link). Without this change to the line, the following error would be displayed when you run h2 after creating the symbolic link: *Error: Could not find or load main class org.h2.tools.ConsoleCaused by: java.lang.ClassNotFoundException: org.h2.tools.Console* -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/h2-database/39baa772-b8f2-4d7f-930a-5671741f95d0n%40googlegroups.com.
