I run my Java programs on a small Linux laptop and today I installed it again on
a MS Vista laptop.My linux laptop ran quite a bit faster than my Vista laptop and
I decided to find out why.
After a bit of digging I found out that the 'server' hotspot comes with the Linux
JRE distribution but it isn't there in the MS Windows distribution; it comes with
the JDK though.
This is what I'm talking about: go to your JAVA_HOME location; that location
typically is c:\Program Files\Java. Look in the jreXXX\bin directory where XXX is
the version of your JRE. You'll find two subdirectories there: client and new_plugin.
On a Linux distribution you'll find another subdirectory there: server. If you go to
the JAVA_HOME\jdkXXX\jre\bin directory (XXX is the version of your JDK) you
do find a 'server' subdirectory. That is the one I was looking for.
Copy that entire subdirectory to your JAVA_HOME\jreXXX\bin directory so that
you end up with three subdirectories there: new_plugin, client and server.
Now you can use the -server flag for your java.exe or javaw.exe tools. What does
it do? It starts up the 'server' version of your JVM which basically means a better
hotspot mechanism (Sun calls it a more 'aggressive' mechanism) and another
optimizing JIT compiler (Just In Time compiler). So what?
That 'server hotspot' thing results in the following timing results for a few tests I
ran: client: 201s versus server: 95s; that means the server version is twice as
fast as the client version or even a bit faster.
On the other hand, the server version starts my application a bit slower and it is
a real cpu hog; i.e. other applications are a bit less responsive and my task
manager showed that both of my cores were really busy. I don't care, I want speed.
So if you want speed as well: copy that 'server' subdirectory from the JDK to
your JRE (see above) and use that -server flag when you start your JVM.
On my Linux distribution the -server option seems to be the default; I'm not sure
though; I'll experiment a bit more. The -server option doesn't buy you much when
you have to run small applications or applications that are highly interactive. The
cpu is just waiting for the user to click something and both versions are very
good at waiting for something ;-)
Concluding: now both of my Java installations on both my Linux and MS Vista
laptops run at comparable speed.
kind regards,
Jos