Question about Java. I'm using Eclipse, and I've created a simple project called Main. In this project there's a class called MainClass.
public class MainClass
{
}
I have another project called Math. It has only one class called Functions, and it's got one method called add:
public class Functions
{
public int add(int a, int b)
{
return a+b;
}
}
I've exported this project called Math into a .jar file. I want to use the add method from the .jar file in the project Main, for example:
public class MainClass
{
int x = add(1, 2);
}
What do I have to do? Thanks for your time.
Edit: Ok, I've added the jar in the lib folder, but now, how do I use add(int a, int b)? It says it is "undefined".
2nd Edit: I created an instance of the class Functions, so now I can use the methods. Thanks for your replies!