Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to Import new version of a class from a jar file created in another Maven project(How to Import new version of a class from a jar file created in another Maven project)
How to Import new version of a class from a jar file created in another Maven project [message #1864628] Fri, 29 March 2024 17:25 Go to next message
Michael Mall is currently offline Michael MallFriend
Messages: 1
Registered: February 2024
Location: Kansas City6
Junior Member

I am using the following version of Eclipse .

Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)

Version: 2023-12 (4.30.0)
Build id: 20231201-2043

I have a Maven project, say Project A, with a java file that includes the following import statement.

import org.nhindirect.config.model.Address;

A version of the Address class is also in another java file in another Maven project, Project B. I modified the class in Project B, adding a helloWorld method to it. Then, I ran "mvn clean package" on Project B using the Maven Build... tool in Eclipse to create a jar file.

In Project A, I now want to import the Address class in the newly created jar file instead of importing the old Address class as indicated above. I have added the new jar file to the Build Path of Project B in Eclipse and I can execute the method that calls the helloWorld method within Eclipse. However, when I try to run "mvn clean package" using the Eclipse Build... tool in Project A, I get the following.

"error: cannot find symbol ... symbol: method helloWorld(String)"

I am guessing that the import statement is importing from the old version of the Address class instead of the new one from the jar file when trying to Build Project A in Eclipse. I have been told that Maven does not use the Build Path when performing a Build, which I guess is the issue here.

I have a couple of questions.

1. How do I find the path to the class containing the code that the import statement is importing (i.e. Where is the path to the source of "org.nhindirect.config.model.Address" that the import statement is pointing to)?

2. How do I get Project A to use the new class instead of the old one, when performing a build, assuming that is the issue?

I have also tried copying the jar file to the .../src/main/resources/ directory of Project A, then adding the following to the pom.xml file for Project A.

<dependency>
<groupId>com.config.model</groupId>
<artifactId>sconfig-model</artifactId>
<version>6.0.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/config-model-6.0.1.jar</systemPath>
</dependency>

I then tried to change "import org.nhindirect.config.model.Address;" to "import com.config.model", but in the IDE it says "The import com.config cannot be resolved".
Re: How to Import new version of a class from a jar file created in another Maven project [message #1864643 is a reply to message #1864628] Mon, 01 April 2024 07:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33209
Registered: July 2009
Senior Member
Maybe it's better to ask here:

https://github.com/eclipse-m2e/m2e-core/discussions


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to Import new version of a class from a jar file created in another Maven project [message #1866339 is a reply to message #1864643] Tue, 28 May 2024 01:35 Go to previous messageGo to next message
sob adiet is currently offline sob adietFriend
Messages: 3
Registered: May 2024
Junior Member
When attempting to build Project A in Eclipse, I suspect that the import line is importing from an older version of the Address class rather than the updated one from the jar file. It has been informed to me that the problem here is that Maven does not use the Build Path when doing a Build.
dordle

[Updated on: Tue, 28 May 2024 01:35]

Report message to a moderator

Re: How to Import new version of a class from a jar file created in another Maven project [message #1866357 is a reply to message #1866339] Tue, 28 May 2024 06:09 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33209
Registered: July 2009
Senior Member
Your post is a statement not a question.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:User Libraries
Next Topic:How to Silently Install /Deploy Eclipse IDE for Enterprise Java and Web Developers
Goto Forum:
  


Current Time: Sun Sep 08 09:49:32 GMT 2024

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

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

Back to the top