0

Here is my .sh

JAVA_HOME=./jdk8
JAVA_OPTS="-Duser.timezone=GMT+8 -server -Xms124m -Xmx2048m  -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:./gc.log -XX:+HeapDumpOnOutOfMemoryError"
APP_LOG=./logs
APP_HOME=./
APP_MAIN=com.xxx.xxx
........
for i in ./lib/*.*; do
CLASSPATH="$CLASSPATH":"$i"
done
PD=0
........
nohup $JAVA_HOME/bin/java $JAVA_OPTS -classpath $CLASSPATH $APP_MAIN >> $APP_LOG/nohup.log 2>>$APP_LOG/e.log &

I use IDEA to package my project, and I put the output file in the correct location(lib folder). However, when I execute this sh file, I found the error message in the log file.

enter image description here enter image description here

A JNI error has occurred, please check your installation and try it again.
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Handler

I want to know what I did wrong? Shouldn't I package my project in this way?

Simon Hu
  • 123
  • 1
  • 9
  • Also, I can change the sh to use the -jar way to run my jar file, however, I want to know how can I run my project successfully in -classpath way. – Simon Hu Jun 03 '20 at 06:59
  • Does this help? https://stackoverflow.com/questions/4729863/using-bash-how-do-you-make-a-classpath-out-of-all-files-in-a-directory – Technext Jun 03 '20 at 07:30
  • @SimonHu : Where is `Handler` supposed to be found in your setup? – user1934428 Jun 03 '20 at 10:25
  • @user1934428 `pom.xml` indicates my dependencies, so If I run this project directly in IDEA, the dependencies should be found in my local maven repository. Should I copy all of the jar in my maven repository manually that needed by my project to the output folder? – Simon Hu Jun 03 '20 at 11:05
  • @Technext Thanks in advance, I'll take a look on it right now – Simon Hu Jun 03 '20 at 11:07
  • @SimonHu : At least you need to make sure, that your `CLASSPATH` collects all classes you need, so that Java can find them. Hence, as a first step I would print `$CLASSPATH` and check, whether it contains the `Handler` class. – user1934428 Jun 03 '20 at 11:11

0 Answers0