• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting class not found in running .sh  RSS feed

 
pavi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I have put hello.jar and log4j.jar through ftp in aix server.
i wrote a script to run hello.jar by setting classpath for both the jar files in .sh file.but i get logmanager is not found when running the script file.

help me in resolving this
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently the classpath is set incorrectly. Please post your script, and the full path names for the script and both jar files. Also, post the full console output - the command you entered to run the script along with the stack trace for the class not found exception.
 
pavi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my script file is test.sh:
#!/bin/sh
JAR_DIR=/path/ToMyJarFile
ClASSPATH=$CLASSPATH:"$JAR_DIR/hello.jar //my java program
ClASSPATH=$CLASSPATH:"$JAR_DIR/log4j.jar
ClASSPATH=$CLASSPATH:"$JAR_DIR/xmlParserAPIs.jar
ClASSPATH=$CLASSPATH:"$JAR_DIR/xercesImpl.jar
export CLASSPATH=$CLASSPATH
PARM="-Dlog4j.configuration=log4j.xml" //this file is included in the hello.jar
cd $JAR_DIR
parm=$@

if [`pwd` != "$JAR_DIR"] ;
then
echo "Can't change to $JAR_DIR."
exit 1
else
java $PARM -jar myJar.jar $parm
wait

fi

i gave ./test.sh welcome

i am getting the java class is not found:/org/apache/log4j/LogManager.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClASSPATH=$CLASSPATH:"$JAR_DIR/hello.jar //my java program

a) CLASSPATH is not ClASSPATH - unix is case sensitive.
b) opening double quotes " are never closed / not in that line.
c) for comments in the shell use #, not //
[ August 14, 2008: Message edited by: Stefan Wagner ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!