Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is -server option there when server VM is the default option?

Tags:

java

jvm

The help menu for java command says that -server option is to select the "server" VM. It also states that 'server' is the default option. Why so redundant?

edit:

If it is of any help, "java -version" yields:

java version "1.8.0_191"
Java(TM) SE Runtime Environment (buil 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
like image 498
Chief A Avatar asked Dec 21 '18 13:12

Chief A


3 Answers

-client and -server are ignored on modern JVMs, as easy as that. There are two JITcompilers C1 and C2, but there are 5 tiers, all the details in the entire glory are here in the comments.

These flags used to control how C1 and C2 would act - disable or not; this is now controlled by two other flags : XX:-TieredCompilation -XX:TieredStopAtLevel=1

like image 162
Eugene Avatar answered Oct 17 '22 12:10

Eugene


I don't know your java version, IMHO, in java8 or older versions, for different platforms(different architecture and OS, or even different cup cores and memory), there are different default JVM(server or client).

This picture is taken from https://docs.oracle.com/javase/8/docs/technotes/guides/vm/server-class.html, we can see the situation for java6.

enter image description here

(Note: For Java SE 6, the definition of a server-class machine is one with at least 2 CPUs and at least 2GB of physical memory. )

Update:

I can only confirm that these options are also provided by java8(1.8.0_121). Not sure for java9 or later.

like image 39
ZhaoGang Avatar answered Oct 17 '22 10:10

ZhaoGang


The -server mode might be default in most JVM versions but there are exceptions. As per Where do I get the server and client systems? docs:

Client and server systems are both downloaded with the 32-bit Solaris and Linux downloads. For 32-bit Windows, if you download the JRE, you get only the client, you'll need to download the SDK to get both systems.

For 64-bit, only the server system is included. On Solaris, the 64-bit JRE is an overlay on top of the 32-bit distribution. However, on Linux and Windows, it's a completely separate distribution.

At the end of the day you can use -client to switch back to client mode and sacrifice JIT optimization for faster startup time.

like image 3
Karol Dowbecki Avatar answered Oct 17 '22 10:10

Karol Dowbecki