I have downloaded Java on mac mavericks system. But when I type on terminal to see the Java version using command:
java version
I get the following error
Could not find or load main class version
I went to oracle website and tried a check to see if Java is installed on my system,which confirmed the Java7 is installed on the system. But why can I not see version in terminal?
The Java “Could not find or load main class” error is thrown when the JVM fails to find or load the main class while executing a program. It usually occurs when executing a Java program from the command line. The "Could not find or load main class" error occurs when the JVM fails to load the main class.
Error: Could not find or load main class ClassName. Error: Could not find or load main class ClassName. The error is mostly generated when we incorrectly specify the class name at run time of the program.
The error generates because the JVM fails to load the main class or package name. There are some other reasons that generate the same error, as follows: The class has been declared in the wrong package. Dependencies missing from the CLASSPATH.
The error is mostly generated when we incorrectly specify the class name at run time of the program. The error generates because the JVM fails to load the main class or package name.
Try
java -version
Without the minus sign it is trying to load a program called version.
java –version
will cause the same error (copied from webpage) as "–" is an em dash
java -version is the command to check java version
Download latest Java SE from Oracle site and install it. Then reopen cmd and check java version using java -version.
Set the Java path to bin and check it's version also. Both java and javac should be on same version.
In my case:
C:\Users\darshan>java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
C:\Users\darshan>javac -version javac 1.8.0_121
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