A map, as suggested in the comments, could be your best bet, as in this case reflection might not be the best practice.
To be able to call it from anywhere in your program, you'd need something like the Singleton pattern, which has to be handled with care:
public class ClassNameHandler {
private static ClassNameHandler instance = null;
protected ClassNameHandler() {
// Exists only to defeat instantiation.
}
public Map<String, File> map = new HashMap<String, File>();
public File f = ClassName.f;
map.put("ClassName.f", f);
//Add more files or variables to the map
public static ClassNameHandler getInstance() {
if(instance == null) {
instance = new ClassNameHandler();
}
return instance;
}
}
Then, elsewhere, you could use something like :
String str = "ClassName.f";
ClassNameHandler.map.get(str);
Double check the singleton pattern for implementation. If it sounds like too much, then there may be other options available but you did not provide much context or what the purpose of your application is, so it depends.
String str=ClassName.f;this should work