Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Eclipse show the startup interface so fast

Java programs start slowly.

I program a JavaFX desktop software. When I double click the executable jar, it costs nearly 5 seconds to show the window. I think the JVM spends a little time to load the class.

But when I open Eclipse, the progress GUI is showed immediately. How can I do that like Eclipse? Does it use other technology to show the GUI without JVM?

like image 674
S.Lee Avatar asked Jan 30 '23 23:01

S.Lee


2 Answers

The 'eclipse' executable is actually a small C program (source code is here).

This reads the eclipse.ini, displays the splash screen if it is specified and then initializes the JVM using the parameters specified in the eclipse.ini and starts the main Eclipse Java code. So the JVM initialization and Java startup is done with the splash screen already displayed.

The Java code is given a reference to the splash window so it can update the progress and close the window when done.

If you write an Eclipse RCP the same code is used to start your RCP.

like image 59
greg-449 Avatar answered Feb 02 '23 11:02

greg-449


The secret is: which classes are used to display that "splash screen"?!

Guessing here: the eclipse people have fine-tuned that code. It might be possible that they use AWT only components there. Well, I stay corrected: they are not using java at all for the splash screen (see the other answer). No surprise.

Beyond that, anecdotal answer on splashing with Java: many years ago I wrote a Swing application. Of course, the customer wanted a nice splash screen, with the company logo and a progress bar; showing the amount of loaded "modules". I coded the first version using swing panels. That panel came up after 15 seconds (no SSDs back then), and 3 seconds later, 100% were reached. Solution back then: I wrote a new version that went with a minimal number of AWT components. In the end, that splash screen looked a little bid "less nice" - but it came up after say 3, 5 seconds.

I think I even tampered with class loading order to ensure that all "expensive" classes were loaded after I pulled the stuff required to show the splash screen.

( and in case this doesn't result in "enough delay" between "splash showing up" and "application fully loaded" ... one could simply extend the "life time" of the splash screen by simply having it sit there a bit longer. sure, you don't tell the customer about that ;-)

like image 37
GhostCat Avatar answered Feb 02 '23 12:02

GhostCat