0

I have a snmp agent running in my machine, which will run a shell script when a snmpwalk request came to the agent with a particular OID. By

exec TestFile /bin/sh /location/of/file/testShFile.sh

Then the sh file in turns call a java file to check the connectivity to other server and returns the o/p to snmp request.

Java file is in package --> a.b.foo.test.Test.java and sh file also resided in --> a.b.foo.test.testShFile.sh

Now how to run the java file from this shell script, as i am getting a NoClassDefFoundError.

3
  • Can you paste your sh file code i mean calling java file lines Commented May 16, 2013 at 13:27
  • # bin/sh cd a/b/foo/test javac Test.java java Test Commented May 16, 2013 at 13:38
  • There is no such thing as a package for shell scripts. Commented May 21, 2013 at 2:53

2 Answers 2

1

Extend your shell batch file to output or log the current setting of the classpath. Probably its not set at all.

Why don't you directly invoke the other Java method?

Sign up to request clarification or add additional context in comments.

2 Comments

Because in snpm agent file i think we cant invoke .class files. If u look at the command, snmp cant recognize java
Well you could immediately spawn another thread which invokes the other method. This would free any listeners in the snmp agent. Its a standard way to handle this kind of request.
0

java -classpath /location/of/parent/of/A/directory a.b.foo.test.Test

Comments

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.