PokeAPI / pokekotlin

Kotlin (or Java, Scala, etc) client for PokeApi
Apache License 2.0
172 stars 43 forks source link

Classes not identified #73

Closed BenjaminChilson closed 4 years ago

BenjaminChilson commented 4 years ago

When trying to use the classes defined in the example case of the project:

PokeApi pokeApi = new PokeApiClient();

neither PokeApi nor PokeApiClient are being recognized as known classes

sargunv commented 4 years ago

What's the exact error message? IDE? Could you post your project anywhere? (Or send it to me privately if it needs to stay private)

BenjaminChilson commented 4 years ago

Here is a link to my project so far on github. It's at a bare minimum now. Just trying to get the client to work on it to get started

https://github.com/BenjaminChilson/PokemonProject

sargunv commented 4 years ago

That’s a 404; is it a private repo?

BenjaminChilson commented 4 years ago

It should be public now

sargunv commented 4 years ago

mvn compile worked for me after I added the import. What's the error you're getting? What exactly are you trying to do? Did you forget the import?

import me.sargunvohra.lib.pokeapi.client.*;

BenjaminChilson commented 4 years ago

I definitely did not include that import. That is surely the last piece to this puzzle. Hopefully one final question. When I simply paste import me.sargunvohra.lib.pokeapi.client.*; at the end of my list of imports it gives the message package me.sargunvohra.lib.pokeapi.client does not exist. Is there any other steps I may be missing for it to find this package?

sargunv commented 4 years ago

Ah sorry, it’s me.sargunvohra.lib.pokekotlin.client.*

Your Java IDE should be able to find missing imports when you type out the class name

sargunv commented 4 years ago

Or if you’re not using an IDE you can just browse the repo to find the right import: https://github.com/PokeAPI/pokekotlin/tree/master/src/main/kotlin/me/sargunvohra/lib/pokekotlin/client

BenjaminChilson commented 4 years ago

I am using an IDE. However even with import me.sargunvohra.lib.pokekotlin.client.*; it is giving me.sargunvohra.lib.pokekotlin.client does not exist

sargunv commented 4 years ago

Which IDE? How did you import the dependencies configured in your maven? Do other libraries work?

BenjaminChilson commented 4 years ago

It is the netbeans IDE. I'm unsure of what you mean by how did I import the dependencies configured in my maven, as I am still beginning to understand maven. The only thing I have done with maven is add the dependencies to the pom.xml file and attempt to run the program. The only libraries I have used up to this point are mainly the java or javafx libraries and so this would be my first external library that I am importing.

sargunv commented 4 years ago

I'm not familiar with NetBeans, but usually IDEs have a button to "import" Maven projects, which reads the pom.xml file and adds the library jars to the compiler classpath. If a project is already imported, sometimes you need to "sync" the project to pick up edits to the pom.xml file.

Are you able to compile from the command line? Try mvn compile from your project root. If that works, then we know the problem is finding how to import/sync the project to your IDE.

BenjaminChilson commented 4 years ago

I see the dependencies jars added folders of my project. I have run mvn compile from terminal and received a BUILD SUCCESS.

Screen Shot 2020-05-09 at 10 15 53 PM

looking into how to sync the project to see these edits

sargunv commented 4 years ago

I installed NetBeans and tried opening your project; seems like the pom.xml is recognized and imported automatically, at least on initial load: https://streamable.com/l8yx5n

sargunv commented 4 years ago

I see in your screenshot that the correct dependencies are present in the tree view on the left, so the pom was synced. Perhaps restart NetBeans? Or try the "Clean and Build" button? What does NetBeans show you inside the pokekotlin jar? It should look something like this:

image

BenjaminChilson commented 4 years ago
Screen Shot 2020-05-09 at 10 52 25 PM

the contents inside of my jar seem different and I am not sure why that is. I also did a re-install of netbeans to see if that solved anything, It did not.

sargunv commented 4 years ago

That's really strange, I'd investigate the cached artifacts in ~/.m2/repository, or perhaps just delete that directory and have maven redownload them. Do the other dependencies appear correct?

BenjaminChilson commented 4 years ago

THATS IT! Deleting and repopulating that folder fixed that jar file and now recognizes that package and even prompts the import as in your screen recording. Thanks so much for all the help!