Java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver On Android

31,480

Solution 1

I had the same problem with my Android app in Eclipse. What worked for me was to export the external jars with my app.

If you have already added the jtds-1.2.5 driver, good. Otherwise:

Right click on the Project > Properties > Libraries Tab Add the jtds-1.2.5.jar file by clicking on "Add External JARs"

Next, in the Order and Export tab (Right next to Libraries in the Java Build Path window) check the box for jtds-1.2.5.jar (and any other external jars you might have).

This will export the .jar containing the driver with the .apk file.

Solution 2

If you use a third party library, make sure you have all its required dependencies, if it requires any.

Solution 3

If you are using eclipse, Try this steps

  • Right click on your project
  • Click Build Path > Configure Build Path...
  • Choose Libraries tag and click Add External JARs...
  • Point your jtds.jar and click OK.
  • Rebuild and run again.
Share:
31,480
user1153176
Author by

user1153176

Updated on July 09, 2022

Comments

  • user1153176
    user1153176 almost 2 years

    Today I am doing Connectivity of SqlServer using JTDS driver. But when I run program I found Below error

    Java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
    Caused by: java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver in loader dalvik.system.PathClassLoader[/data/app/com.kmkm.lll-2.apk]
    

    I already search on this topic and I found answer as

    java -classpath .:jtds.jar MyApp 
    

    but I am confuse how and where I run this command? Why this error comes?

  • JRomero
    JRomero over 11 years
    There seems to be an issue when using 1.3.0 drivers. This is how I found this answer which didn't work. I then downgraded to 1.2.7 and putting it in the libs directory everything worked as expected.