I thought when Java classes are in the same directory, you don't need to import another class when you use it inside another. I have this class that will initiate Cloudinary uploading of files back to the cloud, but when I call it inside another class and run build I get this error 'cannot access CloudinaryUpload'
The Cloudinary class
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.cloudinary.Cloudinary;
import com.cloudinary.utils.ObjectUtils;
public class CloudinaryUpload {
public static void main(String arg[])throws Exception{
Map config = ObjectUtils.asMap(
"cloud_name", "name",
"api_key", "api_key",
"api_secret", "api_secret",
"secure", true
);
Cloudinary cloudinary = new Cloudinary(config);
}
}
Just a snippet of code of another class where I am calling it
public class ClientManagerServices {
private static final int BYTES_DOWNLOAD = 1024;
//The Cloudinary class
private CloudinaryUpload cloudinaryUpload = CloudinaryUpload();
public static String getMessageBody(Delegator delegator, String requester, String subject, String registryFileId, String clientId) {
GenericValue fileData = null;
GenericValue userData = null;
GenericValue clientData = null;
String bodyToReturn = "";
try {
fileData = delegator.findOne("RegistryFile", UtilMisc.toMap("registryFileId", registryFileId), false);
} catch (GenericEntityException e) {
e.printStackTrace();
}
}
CodePudding user response:
This line:
private CloudinaryUpload cloudinaryUpload = CloudinaryUpload();
If that is supposed to creating new instance it should be
private CloudinaryUpload cloudinaryUpload = new CloudinaryUpload();
Note ... new
. If you leave out the new
, then that is a call to a method named CloudinaryUpload
... and no such method exists in your code.