first find the pid of your java process with:
ps aux | grep java
then replace [TOMCAT_PID] with the process ID you found out above
/opt/jdk1.8.0_151/bin/jmap -dump:format=b,file=$(pwd)/tomcat-jvm.hprof [TOMCAT_PID]
/opt/jdk1.8.0_151/bin/jstack -F [TOMCAT_PID] > threaddump.txt