(Solved) Issue with using an external library

I’m not sure if this is the right sub-forum for this so my apologizes if it is and I don’t exactly see a related question to mine.
In short, my goal is to add the Guava library to take advantage of the Maps file and I’m running into an issue with that after adding the library

I added the library as such:
Tools → Libraries → New Library → Giving it a name and pushing OK → Selecting Add JAR/Folder ->Browsed to the JAR file → Add JAR/Folder → OK. Library now appears under ‘Libraries’ on the Projects tab.

In a file which I am making a map for my item registry, I am using the import statement:
“import com.google.common.collect.Maps” to import the Maps file from the Guava library which I imported earlier. Once that is done I get an error message which points at the “com” part of the import statement and it throws this message “package com.google.common.collect does not exist”.

If anyone has any suggestions I’ll be glad to try them out!

Well that should be the correct process, the only thing I can imagine is that you added a Library but not to the Project itself (however you state Library now appears under ‘Libraries’ on the Projects tab.).

Maybe try restarting the sdk or reopening the project so that it gets parsed again.
Try to use Auto-Complete when typing “Maps”, maybe the package is not correct or something.

You should also be able to open the jar in the sdk to see which classes are part of guava

Thank you for your reply Darkchaos!

On further inspection of restarting the SDK the issue still occurs. And for the Auto-Complete, since the package it resides in is there but the SDK just doesn’t fully acknowledge it (I am able to explore the jar inside the SDK).

I’m going to look into it further by reinstalling the jar file (and verify its integrity) and I’ll post any new findings and steps if I make any progress on it.

Alright so I found the culprit of the issue.

I decided to download the 2nd latest release of guava and went through the steps to add it as a library and this worked over the version I was trying to use. I might’ve read some information wrong on the guava GitHub page and assumed that 27.0 was stable on release, well downgrading to 26.0 fixed the issue. jMonkeyEngine detects the Guava library properly now for some reason. Glad its fixed so I can get back to my project!

3 Likes