Hey

I want to create a JAR library but not sure how to in MyEclipse. Im currently doing it manually using jar command but I cant seem to get it correctly

The library code is:

public class LibAdd
{
	public static int addtwonumbers (int a,int b)
	{
		return a+b;
	}
	
}

From this, I generate the .JAR (using what command in case Im doing it wrong). Named (for example) LibAdd.jar

Then in another project, in the build path, I include the LibAdd.jar and I want to do this:

public class AnotherClass
{
   public static void main(String[] args) 
     {
		LibAdd l=new LibAdd(); //Can I do this,having no main???
                  int x=l.addtwonumbers(2,3);
                  System.println.out(x);
               //OR
                  System.println.out(l.addtwonumbers(8,5);


	}
}

Thanks for the help :)

Hey

I want to create a JAR library but not sure how to in MyEclipse. Im currently doing it manually using jar command but I cant seem to get it correctly

The library code is:

public class LibAdd
{
	public static int addtwonumbers (int a,int b)
	{
		return a+b;
	}
	
}

From this, I generate the .JAR (using what command in case Im doing it wrong). Named (for example) LibAdd.jar

Then in another project, in the build path, I include the LibAdd.jar and I want to do this:

public class AnotherClass
{
   public static void main(String[] args) 
     {
		LibAdd l=new LibAdd(); //Can I do this,having no main???
                  int x=l.addtwonumbers(2,3);
                  System.println.out(x);
               //OR
                  System.println.out(l.addtwonumbers(8,5);


	}
}

Thanks for the help :)

hmm maybe this could help: http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-33.htm. lol sorry peter_budo. haha we used the same thing :)

Edited 4 Years Ago by DavidKroukamp: n/a

Perfect.

Worked perfectly. Thanks. I imagine this is what I need.

This question has already been answered. Start a new discussion instead.