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
1718
votes
51 answers

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

I am trying to use Notepad++ as my all-in-one tool edit, run, compile, etc. I have JRE installed, and I have setup my path variable to the .../bin directory. When I run my "Hello world" in Notepad++, I get this…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
1421
votes
5 answers

What are the -Xms and -Xmx parameters when starting JVM?

Please explain the use of the Xms and Xmx parameters in JVMs. What are the default values for them?
Pankaj
  • 14,638
  • 3
  • 17
  • 23
971
votes
11 answers

How do I write a correct micro-benchmark in Java?

How do you write (and run) a correct micro-benchmark in Java? I'm looking for some code samples and comments illustrating various things to think about. Example: Should the benchmark measure time/iteration or iterations/time, and why? Related: Is…
John Nilsson
  • 17,001
  • 8
  • 32
  • 42
775
votes
37 answers

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6

When trying to run the Example CorDapp (GitHub CorDapp) via IntelliJ, I receive the following error: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How can I modify the IntelliJ settings so…
Joel
  • 22,762
  • 5
  • 26
  • 41
605
votes
13 answers

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?
BobMcGee
  • 19,824
  • 10
  • 45
  • 57
562
votes
31 answers

How to deal with "java.lang.OutOfMemoryError: Java heap space" error?

I am writing a client-side Swing application (graphical font designer) on Java 5. Recently, I am running into java.lang.OutOfMemoryError: Java heap space error because I am not being conservative on memory usage. The user can open unlimited number…
Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
422
votes
2 answers

Does Java JIT cheat when running JDK code?

I was benchmarking some code, and I could not get it to run as fast as with java.math.BigInteger, even when using the exact same algorithm. So I copied java.math.BigInteger source into my own package and tried this: //import…
Koen Hendrikx
  • 2,243
  • 2
  • 9
  • 7
421
votes
11 answers

Real differences between "java -server" and "java -client"?

Is there any real practical difference between "java -server" and "java -client"? All I can find on Sun's site is a vague "-server starts slower but should run faster". What are the real differences? (Using JDK 1.6.0_07 currently.)
Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
394
votes
21 answers

Why would you ever implement finalize()?

I've been reading through a lot of the rookie Java questions on finalize() and find it kind of bewildering that no one has really made it plain that finalize() is an unreliable way to clean up resources. I saw someone comment that they use it to…
Spencer Kormos
  • 8,381
  • 3
  • 28
  • 45
373
votes
22 answers

What is the difference between JVM, JDK, JRE & OpenJDK?

What is the difference between JVM, JDK, JRE & OpenJDK? I was programming in Java and I encountered these phrases, what are the differences among them?
Alireza
  • 4,347
  • 3
  • 20
  • 31
363
votes
20 answers

How do I set the proxy to be used by the JVM

Many times, a Java app needs to connect to the Internet. The most common example happens when it is reading an XML file and needs to download its schema. I am behind a proxy server. How can I set my JVM to use the proxy ?
Leonel
  • 28,541
  • 26
  • 76
  • 103
356
votes
3 answers

Java heap terminology: young, old and permanent generations?

I'm trying to understand What the concepts of young, old and permanent generations are in the Java heap terminology, and more specifically the interactions between the three generations. My questions are: What is the young generation? What is the…
knorv
  • 49,059
  • 74
  • 210
  • 294
322
votes
27 answers

Could not reserve enough space for object heap

I am getting the following exception repeatedly each time I try to run the program. Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. I tried to increase my virtual…
Narendra
  • 5,635
  • 10
  • 42
  • 54
315
votes
16 answers

What are the best JVM settings for Eclipse?

What are the best JVM settings you have found for running Eclipse?
Craig Angus
  • 22,784
  • 18
  • 55
  • 63
302
votes
4 answers

Difference between thread's context class loader and normal classloader

What is the difference between a thread's context class loader and a normal class loader? That is, if Thread.currentThread().getContextClassLoader() and getClass().getClassLoader() return different class loader objects, which one will be used?
abracadabra
  • 3,067
  • 3
  • 17
  • 7
1
2 3
99 100