I am starting a Java application with the following command line arguments:
java -Dcom.sun.management.jmxremote.port=12312 \
-Dcom.sun.management.jmxremote.rmi.port=12313 \
-Dcom.sun.management.jmxremote.authenticate=false \
Main
My program exits immediately and I get the following error:
Error: Exception thrown by the agent : java.lang.NullPointerException
I am using Java 8 update 45 on Windows 7:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
In Java, the java. lang. NullPointerException is thrown when a reference variable is accessed (or de-referenced) and is not pointing to any object. This error can be resolved by using a try-catch block or an if-else condition to check if a reference variable is null before dereferencing it.
The java. lang. NullPointerException is a runtime exception in Java that occurs when a variable is accessed which is not pointing to any object and refers to nothing or null. Since the NullPointerException is a runtime exception, it doesn't need to be caught and handled explicitly in application code.
NullPointerException is a runtime exception and it is thrown when the application try to use an object reference which has a null value. For example, using a method on a null reference.
You can also throw a NullPointerException in Java using the throw keyword.
This error occurs if com.sun.management.jmxremote.rmi.port
is set to a port that is already in use. Try setting the property to a free port or killing the process that is currently using the port in question.
There is a reported bug here in Open JDK to improve this error message. It is fixed in Java 8 update 60 and Java 7 update 80.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With