Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Project Cannot see exported Jar(Exported Jar is added to configuration path but not seen)
Project Cannot see exported Jar [message #1838671] Wed, 03 March 2021 07:03 Go to next message
Eclipse UserFriend
I created a very simple Java project with a single class that has a single method to add 2 numbers together.
I export the project as a Jar file.
I add the Jar file to a new project using Build Path-> Add External Archives
I can see the class and method in the Jar file.
I exported both class files and Java files.
However an error occurs when I reference them in the code.
I have attached a screenshot. ClassLib is the original project I exported the Jar from. ClassLIb2 is where I am trying to use it.
Any ideas why this is happening.
Re: Project Cannot see exported Jar [message #1838683 is a reply to message #1838671] Wed, 03 March 2021 09:07 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Is method add define as static ?

Regards.



Re: Project Cannot see exported Jar [message #1838685 is a reply to message #1838683] Wed, 03 March 2021 09:18 Go to previous messageGo to next message
Eclipse UserFriend
No - it's not defined as static. I have included a screenshot.
  • Attachment: classpic.PNG
    (Size: 38.74KB, Downloaded 80 times)
Re: Project Cannot see exported Jar [message #1838716 is a reply to message #1838685] Thu, 04 March 2021 00:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

It seems your problem has nothing to do with eclipse.

You need to call your method as Instance method.

Example:


package examples;

public class MySimpleClass {

	public static int add_UsingStaticMethod(final int a, final int b) {
		return a + b;
	}

	public int add_UsingInstanceMethod(final int a, final int b) {
		return a + b;
	}

}



package examples;

public class Main {

	public static void main(final String[] args) {
		new Main();
	}

	/**
	 * Using MySimpleClass
	 */
	public Main() {

		System.out.format("add_UsingStaticMethod %d \n", MySimpleClass.add_UsingStaticMethod(10, 20));

		// Note the use of "new"
		System.out.format("add_UsingInstanceMethod %d \n", new MySimpleClass().add_UsingInstanceMethod(11, 21));

	}

}



Advice: get The Java Tutorials Bundle and start from the beginning
https://www.oracle.com/java/technologies/javase/java-tutorial-downloads.html

Regards.




Re: Project Cannot see exported Jar [message #1838735 is a reply to message #1838716] Thu, 04 March 2021 04:57 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your reply. So in all scenarios where I am exporting Jar files, do I need to call my method as an instance method?
Re: Project Cannot see exported Jar [message #1838742 is a reply to message #1838735] Thu, 04 March 2021 06:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

You can have both Static and Instance methods in the same exported jar.

It depends on the requirement and design of the application.

Do you want to Zoom ? Send your email or mobile phone number.

Regards.
Eitan.
Re: Project Cannot see exported Jar [message #1838747 is a reply to message #1838742] Thu, 04 March 2021 08:01 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Eitan,
I have got it working now and I understand it,
Thank you - no need to zoom!I appreciate the help!
Re: Project Cannot see exported Jar [message #1838750 is a reply to message #1838747] Thu, 04 March 2021 08:15 Go to previous message
Eclipse UserFriend
You are welcome.
Previous Topic:Launch fails on one computer but succeeds on another
Next Topic:Remote debugging
Goto Forum:
  


Current Time: Tue Jul 15 13:58:48 EDT 2025

Powered by FUDForum. Page generated in 0.07660 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top