Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes java.lang.ClassNotFoundException in running code

This error : java.lang.ClassNotFoundException : javax.xml.soap.SoapException

I can see javax.xml.soap.SoapException is on the classpath so what could be causing this error ?

In more general terms how could a java.lang.ClassNotFoundException be thrown in running code, should the compiler not catch this error ? The only situation I could this occurring is that if a jar was built using a library and the library that jar depends on is not on the classpath when using the jar.

like image 728
blue-sky Avatar asked Jun 19 '26 16:06

blue-sky


1 Answers

The classpath you use to compile an app, is not the same as the classpath you use to run the application. When an application is run using java you still need to have the -cp to load all the supporting jars

like image 171
tik27 Avatar answered Jun 22 '26 05:06

tik27



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!