I tried java --version in the command line and I get :
Unrecognized option: --version
Error: Could not create the Java virtual machine
Error: A fatal exception has occurred. Program will exit.
Everything was working fine until I installed jre 7 (I had jdk 1.6 preinstalled )
So, I uninstalled the previous versions, restarted and then installed fresh jdk 7u5 windows i586.
Still I get the same problem. Can anyone help me with this?
I am unable to install and run maven for this reason.
You used two - marks. Try with one: java -version.
Update: Since Java 9 java and javac commands support both --version and -version.
java -version
This is the command to get the current installed version info
Related
In my university we are learning about writing RMI applications. When I first tried running the example application in Eclipse 2019-03 I ran into the error:
java.lang.UnsupportedClassVersionError
I successfully ran other projects (non RMI) without any problems.
When I run
java -version
I get:
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)
and
javac -version
I get:
javac 11.0.3
I have Java 8 and 11 installed on my system running Ubuntu 18.04.
When looking for a solution to the problem, I found this question:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
Changing the settings of the compiler compliace level in Eclipse to 1.8 did AND changing the project specific Settings helped me and I was able to finally run the Application without any errors. This solution does not satisfy me though.
When I run
update-alternatives --config java
and
update-alternatives --config javac
in both cases openjdk11 is selected.
I do not understand, why I get the error if i dont change the compiler settings.
One of the answers suggested it is a wrongly set $JAVA_HOME varable. When I run:
jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'
It indeed gives me the answer
/usr/lib/jvm/java-8-openjdk-amd64/jre
I tried following this guide to change it to openjdk11:
https://askubuntu.com/questions/175514/how-to-set-java-home-for-java
When I now run
echo $JAVA_HOME
I get:
/usr/lib/jvm/java-11-openjdk-amd64
but when I run
jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'
again the answer is still the same.
I want to be able to use my openjdk 11 to compile and run the code without changing the compiler settings in Eclipse. Anybody had the same problem and a tip for me?
Thank you in advance!
The full error is the following:
java.lang.UnsupportedClassVersionError: chapter6/Counter has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
The /etc/alternatives is ignored when running inside Eclipse. Instead, you have a separate definition of which JDK/JRE to use. This can be set globally in the Eclipse Preferences, one-by-one in the Project Properties, or even at the Debug/Run configuration (in order to test your application in multiple java versions).
I tried installing jenkins on Ubuntu 14.04.5 and ended up with some errors saying,
Setting up jenkins (2.80) ...
Found an incorrect Java version
Java version found:
java version "1.7.0_131"
OpenJDK Runtime Environment (IcedTea 2.6.9) (7u131-2.6.9-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)
Aborting
invoke-rc.d: initscript jenkins, action "start" failed.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
As jenkins requires Java 8 to run, I tried installing Java 8 and again getting the same error mentioned above. I have tried removing jenkins, ended up with the same error "Found an incorrect Java version".
I need help to get this issue resolved. Thanks in advance.
Have a look here:
can't upgrade jenkins for java version error
If that does not help:
Have you checked alternatives and JAVA_HOME? If not, please check the output of these commands:
update-alternatives --config java
echo $JAVA_HOME
Both should be set to java 8 values.
I have just installed Java SE Development Kit 8u91 on my 64 bit Windows-10 OS. I set my path variables . I tried java --version in my command prompt it gave me an error.
c:\Users\Onlymanu>java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
But when i tried java -version it worked.
I tried initializing _JAVA_OPTIONS environment variable and ever tried re-installation none of them worked. Can any one help me please?
I think you have put command like java -VERSION. This is in capital letters
You need to put all command in lowercase letters
javac -version
java -version
All characters must be in lowercase letter
I was facing a similar issue. Actually the command is :
java -version and not java --version.
You will get output something like this:
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
Java 8:
java -version
Java 9+:
java --version
the command should be java -version
Try executing below command,
java -help
It gives option as,
-version print product version and exit
java -version is the correct command to execute
--version is a valid option from JDK 9 and it is not a valid option until JDK 8 hence you get the below:
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
You can try installing JDK 9 or any version later and check for java --version it will work.
Alternately, from the installed JDK 9 or later versions you can see from java -help the below two options will be available:
-version print product version to the error stream and exit
--version print product version to the output stream and exit
where as in JDK 8 you will only have below when you execute java -help
-version print product version and exit
I hope it answers your question.
Your command is wrong.
Linux
java -- version
macOS
java -version
You can't use those commands other way around.
This happens because the CMD doesn't recognize the "java --version" try writing "java -version"
when "java --version" it tries to create a JVM. IT Fails because that's wrong command.
java -version
java -showversion
Both commands work In Linux 16.04 LTS
I'm trying to make Standford NER package to work on my mac. Using anaconda and python 2.7 (iPython notebook). I was following the steps given here:
http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford. While executing the last step, it gave me UnsupportedClassVersionError.."xy.z" is "52.0" which means I need to upgrade to java 8.
I upgraded to Java 8, but my java -version command still showing java 7. So I tried to fix it using the solution given here: After upgrading to Java8, javac still shows 1.7. Instead of removing, I renamed the directory. These are the following commands I exec:
cd /System/Library/Frameworks/JavaVM.framework/Versions/
mv Current Current_Old
ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/ Current
Then after that java -version command is not working. I realized the directory name is incorrect and tried to replace it back using mv Current_Old Current, still the command is not working.
how can I restore my java?
Able to get it working again! All I did was restored legacy Java 6 from this link: https://support.apple.com/kb/DL1572?locale=en_US
Then java -version was even showing me the latest version which is Java 1.8. Able to start Java IDE now.
When I try to use the eclipse.exe file to start the eclipse it fails. This issue started occuring after I installed JDK 7 on my system .
When I use the command line paramater
eclipse -vm "C:\Program Files\Java\jdk1.7.0_06\bin"
eclipse starts just fine. I am assuming it is something related to the JVM which has caused the issue.
Meanwhile when I try to check java version I get the following error:
C:\Test>java -version
Error occurred during initialization of VM
Not sure if the two are related.
java -version failing indicates to me that you probably need to configure the OS environment variables,
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_06
Path=...;%JAVA_HOME%\bin;