I have a project \"A\" and I need to call a class \"c\" from another project \"B\".
I have done the following. Click in \"A\" -->Properties -->Build Path --> and in
In order to call methods from Classes in Java, you first need the instance of the class.
So in your code you need to do something like the following:
acquiring instance:
MyClass instanceOfMyClass = MyClass.getInstance();
calling the method:
instanceOfMyClass.someFunction(...);
This means that when you call getInstance() it will return instance of MyClass if such an instance already exists, or it will create a new one, if there's no instance. After acquiring an instance of a class, you simply call it's methods, if they have the appropriate access modifiers.
As per java doc java.lang.classNotFoundException comes in following cases:
To Resolve the above exception we need to:
First find out the jar file on which problematic class file is present for example in case of "com.mysql.jdbc.driver" its mysql-connector-java.jar. If you don't know how to find which jar file a particular class you can simply do "Ctrl+T" in Eclipse and type the name of class, It will list all the jar in the order they appear in eclipse classpath.
Check whether your classpath contains that jar, if your classpath doesn't contain the jar then just add that class in your classpath.
If it’s present in your classpath then there is high chance that your classpath is getting overridden or application is using classpath specified in jar file or start-up script and to fix that you need to find the exact classpath used by your application.