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 try:
boolean inJar = false;
try
{
CodeSource cs = DataResolver.class.getProtectionDomain().getCodeSource();
inJar = cs.getLocation().toURI().getPath().endsWith(".jar");
}
catch (URISyntaxException e)
{
e.printStackTrace();
}
If you're running from a jar file then cs.getLocation().toURI() will give you the URI of that file; if you're running from inside Eclipse then it'll probably be the path to directory containing your class files.