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 java.math.BigInteger; public class MultiplyTest { public static void main(String[] args) { Random r = new Random(1); long … Read more

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 of files, and the program keeps the opened objects in the memory. After a quick research I … Read more

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? 12 s 12 For certain versions of Java, you can check the bitness of the JVM from the command line with the flags -d32 … Read more

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 that all the bytecode is built with the same JVM target? 34 s … Read more

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 stopwatch benchmarking acceptable? 1Best Answer 11 Tips about writing micro benchmarks from the creators of Java HotSpot: Rule … Read more

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? 5 The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool. This means that your JVM will be started with Xms amount of … Read more

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 message: java.lang.UnsupportedClassVersionError: test_hello_world : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) ………………………………….. … Read more