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

Pectus Excavatum
  • 3,593
  • 16
  • 47
  • 68
  • 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. – umläute Sep 10 '13 at 09: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 `
    ` - which you haven't given)
    – umläute Sep 10 '13 at 09:20

1 Answers1

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
devnull
  • 118,548
  • 33
  • 236
  • 227
  • 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)) – umläute Sep 10 '13 at 09:17
  • Maybe the *assumption* isn't true, but it's a fact that saying `A = foo` won't set the variable `A`! – devnull Sep 10 '13 at 09:21