Hi All,
I have a simple java application which reads data from the DB. The application works fine on windows. I have added the 'mysql-connector-java-5.1.22-bin.jar' in my windows classpath.
The problem comes when i copy the application on linux and run it. I getthe following exception:
Code:
root@HH-Linux1:/opt/integra/middleware/LCPAnalyzer/src# javac LCPAnalyzer.java
root@HH-Linux1:/opt/integra/middleware/LCPAnalyzer/src# java LCPAnalyzer
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at LCPAnalyzer.connectDB(LCPAnalyzer.java:47)
at LCPAnalyzer.main(LCPAnalyzer.java:32)
I have read various articles on setting classpath in linux, but couldn't get through and I am still unclear as to how to set the classpath in linux?
I even copied the 'mysql-connector-java-5.1.22-bin.jar' in my project src folder where the .class file is generated but still no success.
I also tried setting the classpath at runtime by: export CLASSPATH=/opt/integra/middleware/LCPAnalyzer/src/mysql-connector-java-5.1.22-bin.jar
but then i got the follwoing exception:
Code:
root@HH-Linux1:/opt/integra/middleware/LCPAnalyzer/src# javac LCPAnalyzer.java
root@HH-Linux1:/opt/integra/middleware/LCPAnalyzer/src# java LCPAnalyzer
Exception in thread "main" java.lang.NoClassDefFoundError: LCPAnalyzer
Caused by: java.lang.ClassNotFoundException: LCPAnalyzer
I am totally lost as how to proceed now. Could someone please suggest a permanent way to set classpath in linux. I have few other java mail api related jars as well, which i would want to set in the classpath in linux but first want to resolve this mysql connector problem.
Any help woudl really be appreciated.
Thanks