0

I am having some trouble running a few jar's on a linux box. Basically, I am getting an error saying it cannot find the main class of my main jar. The class is defenetly present so it must be a classpath issue. I am not great with linux, so I am looking for some advice as to where I might be missing something.

First off, I am setting the classpath in the users bash_profile; adding all the jar's required, seperated by a : delimeter. I then export the classpath.

Then, in the shell (ksh) script I use to invoke the main jar, I also st the classpath and call it in the command using -cp

so it looks like:

TEST_ROOTDIR = /Test/app
CLASSPATH=$CLASSPATH:${TEST_ROOTDIR}/lib/myjar.jar
...
export CLASSPATH

CMD_STRING="java -Xms200m -Xmx200m -XX:MaxPermSize=200m -verbose -cp $CLASSPATH"
CMD_STRING="$CMD_STRING <main classpath in jar>"

nohup $CMD_STRING > $OUTPUT_FILE

The output file shows all the jre jar's getting executed, it then loads the jar and throws a class not found exception for the main class.

I am stumped, any help would be greatly appreciated

2
  • i'd rather start without all the fancy nohup and variable-thingies; first try getting it to run on the cmdline, e.g. -Xms200m -Xmx200m -XX:MaxPermSize=200m -verbose -cp /Test/app/lib/myjar.jar myjar. once this works, put it into the script. Commented Sep 10, 2013 at 9:12
  • obviously the cmdline should include the java-interpreter itself: java -Xms200m -Xmx200m -XX:MaxPermSize=200m -verbose -cp /Test/app/lib/myjar.jar myclass (and myclass being your <main classpath in jar> - which you haven't given) Commented Sep 10, 2013 at 9:20

1 Answer 1

1

The problem is in the following line:

TEST_ROOTDIR = /Test/app

I'm certain that upon executing the script, it'd have emitted an error message saying:

TEST_ROOTDIR: command not found

which you seem to have ignored. Remove the spaces around = while setting the environment variable. Say:

TEST_ROOTDIR=/Test/app
Sign up to request clarification or add additional context in comments.

2 Comments

the OP states that "it then loads the jar" which seems to indicate that your assumption is not true; (and actually i tried to undo my downvote (without upvoting))
Maybe the assumption isn't true, but it's a fact that saying A = foo won't set the variable A!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.