In the past I've used a bit of a hack to see if my software was running in Eclipse by checking if I could find a .project file.
public static boolean isRunningInEclipse(int folderDepth) {
File projectRoot = new File(Boot.class.getProtectionDomain().getCodeSource().getLocation().getFile());
for (int i = 0; i < folderDepth; i++) {
projectRoot = projectRoot.getParentFile();
if (projectRoot == null || !projectRoot.isDirectory()) {
return false;
}
}
return new File(projectRoot, ".project").isFile();
}
If your main class in located in the bin
folder you call the method with folderDepth = 1, if your main class is located in target/classes/
you call it with folderDepth = 2.
If you specifically want to know if it is running in the debugger I suggest you check this answer