How can a running Java program determine whether it is running from under Eclipse using the Run command (Ctrl + F11) or running under a JVM running from the command line separately from eclipse, such as `> java -cp myPath MyMainClass'?

  • And razve Eclipse does not run the program from the command line with embedded tools? - Andrew Bystrov
  • The environment variable can be set in Eclipse to run. And in the application to check it in System.getenv . - Suvitruf
  • @Suvitruf yes, but I would like to find a simpler way that does not require special gestures from the Eclipse user. I give the project to the customer in the form of (JAR + set of compiled classes + Eclipse project). Future users are not experts on eclipse, and I don’t want to create unnecessary problems for them. There should be very simple procedures described in the short user manual. In the code, you can run as you like, there are no restrictions. - m. vokhm

1 answer 1

The Intelij Idea is added to System.getProperties ():

"idea.launcher.bin.path" with the value "C: \ Program Files (x86) \ JetBrains \ IntelliJ IDEA xxx \ bin"

Tested on Idea 2016.3 under JDK 1.8.0_102

If it doesn't matter to you, you can try the free Community Edition.

In Eclipse, unfortunately, this is not found.

  • Thanks, but I just need eclipse. Idea is no good. - m. vokhm