0

I am trying to run a Java program from the bash shell. The program uses some 3rd party libs (mysql connector , amazon aws)

This is just a standard java program , not running on a J2EE server or anything complicated.

It always complains that it cannot find one of the classes in the third party libs (ClassNotFoundException) (If I remove references to this then it will complain about a different one).

This is confusing since I have checked that the location of the jar files containing the libs is in the classpath. I have also tried putting the libs in the same folder as the .class File I am trying to run to no avail.

I compiled the program using the javac command on the same computer and it had no problems finding the libraries , so I am confused as to why it cannot find them at runtime..

I also tried this from cmd under windows but got the same problem.

The only rational explaination I can find is that it is due to security restrictions in the JVM , in which case it would be good to know how to disable them for this program?

Thanks

1
  • 2
    what does your command line look like? Commented Jan 13, 2011 at 20:11

3 Answers 3

1

Kind of what Bozho said but for jar files you have to call out the jar file by path AND name, just not the path to them. From what I gathered from your post you are only adding the path.

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

Comments

0

It would be better if you had put the commandline that you are using in the question. It is basically something like this java -classpath c:/libs/myjar.jar;c:/libs/myjar2.jar;c:/myclasses MyClass where MyClass is your "main" java class the -classpath option is the list of areas where you want the runtime to look for dependencies. The .jar are jar files and the folder myclasses is a folder where you may have a .class files or other config information that the program may need.

1 Comment

I have tried this, it works ok in windows cmd. But now on linux it claims that it cannot find the MyClass
0

I figured this out for Linux, it's java -classpath "/path/to/jar/myjar.jar:." MyClass

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.