Eclipse Maven dependency jar grayed out, can't import classes from it

I found the issue. It was because I had the class in the source directory instead of the test directory and both of the maven dependencies had been marked as "Visible only to test"


open your pom.xml file check for the name of the grayed out jar file change

<scope>test</scope>

to

<scope>compile</scope>

check for your dependency scope in POM file

compile, provided, system and test these were the available test

test -> compile would change your dependencies from grey to white.

If your dependency is for test scope then that dependency is not available for normal use in application whereas compile scope sets that dependency in class path of your project.