8

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)
Chief A
  • 510
  • 10
  • 24
  • 1
    afaik the -server option is only default if the enviroment meets some specific requirements in term of multicore-cpu and ram size. To be specific i can remember something of 2gb ram, but this could have changed in recent java versions – Meini Dec 21 '18 at 13:49

3 Answers3

14

-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

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • Note: Though @Karol Dowbecki's answer solves my question this answer tells me what I should have been looking instead. I would really like to accept both if I could :( – Chief A Dec 26 '18 at 13:07
5

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.

ZhaoGang
  • 4,491
  • 1
  • 27
  • 39
  • this is plain wrong, these flags in modern jvm are simply ignored – Eugene Dec 21 '18 at 15:15
  • Updated my post. By sying `modern` jvm, do you mean java9 or later? – ZhaoGang Dec 21 '18 at 19:45
  • I'll have to search the code base to get you an exact answer, but I am pretty sure that since java-8 *at least* – Eugene Dec 21 '18 at 19:47
  • and just FYI those pages on oracle website very often have mistakes that are updated not it time, so is the one you just put up. it actually means java-6, but the link contains java-8... this would not be the first time btw, here is [another issue](https://bugs.openjdk.java.net/browse/JDK-8199394) and the [actual talk where it begin with](https://stackoverflow.com/questions/49172698/default-hashcode-implementation-for-java-objects). Notice how Stuart Marks admits this mistake too on the website – Eugene Dec 21 '18 at 19:50
3

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.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • that link looks like a very old and broken, "since java-5"... anyway these `-server` and `-client` are old parameters too and are ignored, thus this is not correct – Eugene Dec 21 '18 at 15:17