Questions tagged [jvm]

The Java Virtual Machine (JVM) enables a set of computer software programs and data structures to use a virtual machine model for the execution of other computer programs and scripts. Use this tag for questions dealing with tools provided by a JVM or how it works in a specific scenario.

The model used by a JVM accepts a form of computer intermediate language commonly referred to as Java bytecode. This language conceptually represents the instruction set of a stack-oriented, capability architecture.

A JVM can also execute bytecode compiled from programming languages other than Java. For example, Ada source code can be compiled to execute on a JVM. JVMs can also be released by other companies besides Oracle (the developer of Java), but JVMs using the "Java" trademark may be developed by other companies as long as they adhere to the JVM specification SE 7 published by Oracle and to related contractual obligations.

List of Java and JVM Specifications 6-11

See also "Understanding Oracle Java SE Licensing".

Java was conceived with the concept of WORA - write once, run anywhere. This is done using the Java Virtual Machine (JVM).

The JVM is the environment in which Java programs execute. It is the software that is implemented on non-virtual hardware and on standard operating systems.

JVM is a crucial component of the Java platform, and because JVMs are available for many hardware and software platforms, can be both middleware and a platform in its own right, hence the trademark write once, run anywhere. The use of the same bytecode for all platforms allows Java to be described as "compile once, run anywhere", as opposed to "write once, compile anywhere", which describes cross-platform compiled languages. A JVM also enables such features as automated exception handling, which provides "root-cause" debugging information for every software error (exception), independent of the source code.

A JVM is distributed along with a set of standard class libraries that implement the Java Application Programming Interface (API). Appropriate APIs bundled together form the Java Runtime Environment ().

Online Resources

  1. JVM Wikipedia
  2. A nice online book on the internals of JVM: Inside JVM by Bill Venners
  3. Java HotSpot VM Options
  4. IBM JVM Documentation
  5. OpenJDK Wiki
  6. Oracle HotSpot Wiki - Has information about JVM internals.

What questions should have this tag?

  1. Questions to know how a JVM works in a specific scenario
  2. Questions which deal with tools provided with a JVM
12159 questions
147
votes
31 answers

Kotlin unresolved reference in IntelliJ

I started off with this tutorial for learning Kotlin in IntelliJ IDEA. When I tried running the following example, fun main(args: Array) { println("lol") } Build fails with the following error: Error:(5, 5) Kotlin: Unresolved reference:…
Anony-mouse
  • 2,041
  • 2
  • 11
  • 23
145
votes
3 answers

Maximum number of parameters in Java method declaration

What is the maximum number of parameters that a method in Java can have and why? I am using Java 1.8 on a 64-bit Windows system. All the answers on StackOverflow about this say that the technical limit is 255 parameters without specifying why. To be…
userv
  • 2,527
  • 4
  • 27
  • 36
144
votes
11 answers

Where are static methods and static variables stored in Java?

For example: class A { static int i=0; static int j; static void method() { // static k=0; can't use static for local variables only final is permitted // static int L; } } Where will these variables be stored in Java,…
Nav
  • 10,304
  • 20
  • 56
  • 83
144
votes
11 answers

How to find the JVM version from a program?

I want to write a sample Java file in which I want to know the JVM version in which the class is running. Is there a way?
java_geek
  • 17,585
  • 30
  • 91
  • 113
136
votes
14 answers

Getting the parameters of a running JVM

Is there a way to get the parameters of a running JVM? Is there a command-line tool, like jstat, which takes as input the PID of the JVM and returns its starting parameters? I am particularly interested in the -Xmx and -Xms values that were given…
H-H
  • 4,431
  • 6
  • 33
  • 41
130
votes
2 answers

Java: int array initializes with nonzero elements

According to the JLS, an int array should be filled by zeros just after initialization. However, I am faced with a situation where it is not. Such a behavior occurs first in JDK 7u4 and also occurs in all later updates (I use 64-bit implementation).…
Stanislav Poslavsky
  • 2,398
  • 2
  • 24
  • 36
126
votes
3 answers

CATALINA_OPTS vs JAVA_OPTS - What is the difference?

I was trying to find out the difference between Apache Tomcat variables - CATALINA_OPTS and JAVA_OPTS in SO and surprised to see that there is no question/answer posted here yet. So I thought of sharing it here (with answer) after finding out the…
Gnanam
  • 10,613
  • 19
  • 54
  • 72
124
votes
8 answers

Jvm takes a long time to resolve ip-address for localhost

I seem to have a problem with performance of "sbt test" (which includes looking up localhost names/IP addresses) after upgrading to macOS Sierra. On a previous version of OS X it took about 40-50 seconds to finish. macOS Sierra times are much higher…
Tomasz Mikus
  • 1,286
  • 2
  • 9
  • 8
120
votes
30 answers

Android java.exe finished with non-zero exit value 1

I've tried looking at similar ones and no solution has worked. I've previously run apps without a problem but my new app suddenly started giving me problems. It always fails when I try to run it saying: Error:Execution failed for task…
Rand
  • 1,653
  • 2
  • 12
  • 15
120
votes
2 answers

limiting java ssl debug logging

Using JVM flag -Djavax.net.debug=ssl is producing a tremendous ammount of logging, the details for every SSL event on the server. Is there anyway to only have it log errors? or possibly there is some better subset of these flags that produce tidier…
Steve Renyolds
  • 1,341
  • 2
  • 9
  • 10
119
votes
5 answers

Why doesn't the JVM cache JIT compiled code?

The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to obtain near-native execution speeds after the code has been run a few times. The question is, why isn't this compiled code cached to disk for…
Chinmay Kanchi
  • 62,729
  • 22
  • 87
  • 114
117
votes
17 answers

Maximum Java heap size of a 32-bit JVM on a 64-bit OS

The question is not about the maximum heap size on a 32-bit OS, given that 32-bit OSes have a maximum addressable memory size of 4GB, and that the JVM's max heap size depends on how much contiguous free memory can be reserved. I'm more interested in…
Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
117
votes
2 answers

Print All JVM Flags

Found an interesting JVM Flag : java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version It prints hundreds of various options, I never heard about before. It also prints default values, that helps diagnose JVM behaviors better. Another…
Sachin Bhansali
  • 1,372
  • 2
  • 9
  • 12
115
votes
6 answers

Why does a 4 billion-iteration Java loop take only 2 ms?

I'm running the following Java code on a laptop with 2.7 GHz Intel Core i7. I intended to let it measure how long it takes to finish a loop with 2^32 iterations, which I expected to be roughly 1.48 seconds (4/2.7 = 1.48). But actually it only takes…
twimo
  • 4,061
  • 5
  • 29
  • 32
113
votes
38 answers

Android Studio Gradle project "Unable to start the daemon process /initialization of VM"

Version of Android Studio (Beta) 0.8.4 OS version: Windows 8 Java JRE/JDK version: 1.8.0_11 Error:Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is…
AsimRazaKhan
  • 2,154
  • 3
  • 22
  • 36