0

I work with Eclipse (Java) on different projects at the same time, let's name them Project1 and Project2.

I'm working on Project1 and I want to import a Class inside a package 'a.b.c' from Project2 : 'a.b.c.Class' Meanwhile, it seems that I got a package named 'a.b' inside my Project1.

This cause an error because when i'm typing :

import a.b.c.Class

It seems like Eclipse thinks that I'm trying to refer to my package 'a.b' from Project1 instead of my package 'a.b.c' from Project2. Eclipse wants me to create a package named 'a.b.c' in Project 1. And indeed when I try to build my project, there is an error.

I know that the packages shouldn't be named like this, but unfortunately it is... Is it possible in any way to import the class I want in my project ?

Thank you

Abstern
  • 61
  • 8
  • 1
    The problem is not the package name, Eclipse just ignores random projects unless you tell it to use them. See the link. – Tom Oct 15 '19 at 13:09

1 Answers1

0

Indeed, I thought the problem was the package name but it was just the fact that Project2 was not in the dependencies of Project1.. Thanks Tom

Can we call another project java class from our project in eclipse

It was a maven project, so I added in the pom.xml my dependency and it solved it.

Abstern
  • 61
  • 8