Arafat Nalkhande
Arafat Nalkhande

Reputation: 11718

Eclipse takes too long to start Program Execution

When I click the "Run" button or the F11 key to start a program execution it takes around 8-10 seconds to start the actual execution.

So considering the following same code

public class Demo {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

After clicking the "Run" button or the F11 key it prints "Hello World" after 8-10 seconds. For bigger programs once the execution has started it runs fairly quick. But the initial starting is the only issue

I am using "Eclipse IDE for Java Developers" Version: 2020-03 (4.15.0)

Have only a minimal set of plugins and infact tried disabling the Mylyn plugin as well but to no avail

Upvotes: 1

Views: 1716

Answers (2)

Arafat Nalkhande
Arafat Nalkhande

Reputation: 11718

Found the issue. It was Dynatrace agent that was causing the problem.

Thanks to @howlger for directing to execute via the "Show Command Line" on the command line, which established the fact that the issue was not caused by Eclipse.

Running the java command with -verbose flag showed the following 3 jars getting loaded

[Opened C:/PROGRA~2/DYNATR~1/oneagent/agent/bin/1.175.224.20190905-115725/any/oneagentjava.jar]

[Opened C:/PROGRA~2/DYNATR~1/oneagent/agent/bin/1.175.224.20190905-115725/any/oneagentjava.rmi.jar]

[Opened C:/PROGRA~2/DYNATR~1/oneagent/agent/bin/1.175.224.20190905-115725/any/oneagentjava.sql.jar]

And then uninstalling the Dynatrace Agent did the trick

Now the program execution starts immediately from command prompt as well as Eclipse

Upvotes: 0

howlger
howlger

Reputation: 34295

This is probably not caused by Eclipse, which can be seen by whether the delay also occurs when running on the command line what you get with the Show Command Line button of the run configuration.

On Windows, it can be caused by the Windows Defender. Excluding the Java installation folder as described here (which will probably be the main reason for you, since Windows Defender scans the entire Java system library on access) and excluding the folders containing the dependencies (e.g. Maven repository) should eliminate the delay. But keep in mind that this also comes with a security risk, especially the exclusion of a Maven repository, where you usually don't pay attention attention to what you download into it.

Startup time can be further reduced by using newer Java VMs or/and using an Eclipse OpenJ9 Java VM with shared classes cache (for me Eclipse and other Java applications start with OpenJ9 in about two thirds of the time than with the HotSpot VM).

Upvotes: 2

Related Questions