Reputation: 165
I made a library in java to make calling maps from google maps easier and faster but I can't seem to import the jar file correctly. I followed the answer I found on this page How to create my own java library(API)? but it seems I am still doing something wrong.
I named the package in the library com.googleMaps and then I exported the .jar file and then added that .jar file into my build path of another project. I then made a class, imported com.googleMaps.StaticMap;
Which gave me an unused library warning. Finally inside my main method I called DisplayMaps("string");
which is a method inside of StaticMap;
But it gives me an error saying the Method does not exist but the unused warning on the import went away.
Error is: The method DisplayMap(String) is undefined for the type MapTest1
Code:
import com.googleMap.StaticMap;
public class MapTest1
{
public static void main(String[] args)
{
DisplayMap("A Url Goes here"); // This is where im getting the error
}
}
Upvotes: 0
Views: 261
Reputation: 393986
You should call it with StaticMap.DisplayMap("A Url Goes here");
. That's assuming it's a static method.
When calling a static method, you have to specify the class it belongs to, unless you are calling it from another method of the same class.
If it's not a static method, you have to create an instance of StaticMap
before calling the method :
StaticMap map = new StaticMap();
map.DisplayMap("A Url Goes here");
Upvotes: 1