Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:03 Go to next message
Mary Looney is currently offline Mary LooneyFriend
Messages: 4
Registered: March 2021
Junior Member
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 14:07 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 86
Registered: October 2018
Member
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 14:18 Go to previous messageGo to next message
Mary Looney is currently offline Mary LooneyFriend
Messages: 4
Registered: March 2021
Junior Member
No - it's not defined as static. I have included a screenshot.
  • Attachment: classpic.PNG
    (Size: 38.74KB, Downloaded 13 times)
Re: Project Cannot see exported Jar [message #1838716 is a reply to message #1838685] Thu, 04 March 2021 05:43 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 86
Registered: October 2018
Member
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 09:57 Go to previous messageGo to next message
Mary Looney is currently offline Mary LooneyFriend
Messages: 4
Registered: March 2021
Junior Member
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 11:57 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 86
Registered: October 2018
Member
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 13:01 Go to previous messageGo to next message
Mary Looney is currently offline Mary LooneyFriend
Messages: 4
Registered: March 2021
Junior Member
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 13:15 Go to previous message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 86
Registered: October 2018
Member
You are welcome.
Previous Topic:Launch fails on one computer but succeeds on another
Next Topic:Remote debugging
Goto Forum:
  


Current Time: Sun Jun 13 12:44:10 GMT 2021

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

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

Back to the top