• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps NullPointerException when .jar file is used

I have an old java application in package "va" and created .jar file from it. While creating the .jar file, I gave the command from outside the va folder (containing classes). When I use the .jar file in another Java application on my desktop, giving java -jar command, it is working fine.
I am creating my first android app and I have placed va.jar in the lib folder and added it as a library. The android app is creating an object of a class (this class contains main method also) in this va package. I have imported va.* and the android app is compiling without any errors.
Here is the code

import va.*;

-------

VarAnalyser obj = new VarAnalyser(); // it is ok up to this point

obj.init(); // null pointer exception

When I execute this on emulater, I am getting NullPointerException on this line.

I created one more app by putting all the .java files of the package "va", and it is working without throwing exception.
How to solve this problem? I want to keep only the .jar file and not the source code of package va.
Thanks in advance.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones