1

So I am trying to import this class from my jar file. IntelliJ recognizes access to all the folder structures but not the class. enter image description here Says: "Cannot resolve symbol 'Constants'.

Note that I have tried clicking "Add library 'premiumdue.main.jar' to classpath" and it still doesn't work.

I have no idea why it won't let me import the class.

Here is a minimal intellij project showing my issue: https://www.dropbox.com/s/xzvv2x1ca2lld26/jar_issues.zip?dl=0

Slaknation
  • 2,124
  • 3
  • 23
  • 42
  • 2
    Did you add this jar to the module dependencies per https://www.jetbrains.com/help/idea/working-with-module-dependencies.html#add-a-new-dependency? If it's already added, please try File | Invalidate Caches | Invalidate and Restart. – CrazyCoder May 03 '22 at 15:42
  • @CrazyCoder Yes I have added it doing it that way. I have already tried doing the invalidate and restart but I will try again. – Slaknation May 03 '22 at 15:45
  • 1
    If the issue persists, please share the [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – CrazyCoder May 03 '22 at 15:46
  • @CrazyCoder I think I've got a project example. How do I share it? Can I upload the IntelliJ project somewhere? – Slaknation May 03 '22 at 19:57
  • 1
    Use any file sharing service. – CrazyCoder May 03 '22 at 19:58
  • Here you go: https://www.dropbox.com/s/xzvv2x1ca2lld26/jar_issues.zip?dl=0 I'm not sure that the jar file will be included in the intellij project (it is on my computer). But I included it in the zipped folder incase it doesn't (and you can add it to the intellij project yourself). – Slaknation May 03 '22 at 21:49

1 Answers1

1

For your sample Gradle project, the dependency jar has to be referenced in build.gradle file as described in this answer.

dependencies {
    implementation files('../create_jar.jar')
}

Proof:

proof

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904