I have an application that some of my users run from Eclipse, and others run it by using a jar file.
I want some actions to be done when running from within the jar,
You could check the system class path property for the Equinox launcher:
if (System.getProperty("java.class.path").contains("org.eclipse.equinox.launcher")) {
System.out.println("You're running inside Eclipse");
}
There are some other potential properties that you may check for, which you can find in Eclipse through Help -> About -> Configuration Details.
Jon's answer is good if you want to know whether you'r running from a JAR versus running from a bunch of class files. But if you use a JAR in both cases then it won't tell you what you need.