it alerted that 'org.eclipse .core .internal.File cannot be cast to org.eclipse.core.resource.IProject'.
Because:
Corrected last 3 lines of your code.
if(selection1.getFirstElement() instanceof IFile) {
IFile file = (IFile) selection1.getFirstElement();
String real_file_path = file.getLocation().toString();
System.out.println(real_file_path);
}