Reputation: 372
I'm still kind of new to java, and one thing I haven't had to work with until now is calling a method from a class that is not in a package that is part of that particular project. I have two jars: ai.jar and functions.jar. Inside functions.jar I have a bunch of classes right inside, so they aren't in folders or anything. Inside ai.jar, I have a class that accesses a particular method inside ai.jar. I've tried to create a reference variable by using functions.jar/get.class
and various other things like that, but I always get a classnotfoundexception. How do I do this? Thanks!
Upvotes: 1
Views: 12073
Reputation: 548
I assume you want to import a jar into your project, for that the instructions are presented below:
Hope it helps.
Upvotes: 4
Reputation: 122026
You have to add them to your Build path
of your project.
Then you just need to import
that class
.
Then create the instance of particular class
if it is a instance
method.
Other wise ClassnameInJar.method();
if it is a static
class.
See examples with screen shots
Upvotes: 8