Solution to the error of javaunrecognizedclassfileversion in linux
Source: Internet
Author: User
Solution to the error of javaunrecognizedclassfileversion in linux-Linux general technology-Linux programming and kernel information. For more information, see the following. Environment: ThizLinux Server7.0 and Fedora6
Problem: java.sun.com downloads the binfiles of jdk1.60 and jre1.60. sh./after installing XX. bin, compile HelloWorld. java to generate the HelloWorld. class file, but java HelloWorld cannot be executed. The following error occurs:
[Root @ Mr javaPC] # javac HelloWorld. java
[Root @ Mr javaPC] # ls
HelloWorld. class HelloWorld. java calculator. java calculator. java ~
[Root @ Mr javaPC] # java HelloWorld
Exception in thread "main" java. lang. ClassFormatError: HelloWorld (unrecognized class file version)
At java. lang. VMClassLoader. defineClass (libgcj. so.7rh)
At java. lang. ClassLoader. defineClass (libgcj. so.7rh)
At java. security. SecureClassLoader. defineClass (libgcj. so.7rh)
At java.net. URLClassLoader. findClass (libgcj. so.7rh)
At gnu. gcj. runtime. SystemClassLoader. findClass (libgcj. so.7rh)
At java. lang. ClassLoader. loadClass (libgcj. so.7rh)
At java. lang. ClassLoader. loadClass (libgcj. so.7rh)
At gnu. java. lang. MainThread. run (libgcj. so.7rh)
[Root @ Mr javaPC] #
Preliminary solution and analysis:
Enter the complete path during execution. As follows:
It can be seen that there is a small problem with PATH.
Check the java version to find out where the problem is.
[Root @ Mr javaPC] # java-version
Java version "1.4.2 ″
Gij (GNU libgcj) version 4.1.1 20061011 (Red Hat 4.1.1-30)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
Warranty; not even for MERCHANTABILITY or fitness for a particle PURPOSE.
[Root @ Mr javaPC] #
Here, the version is "1.4.2", and we have installed 1.6.0, so there is (unrecognized class file version.
Solution:
You can solve the problem by knowing the root cause. How to change the environment variable PATH and so on.
On the Internet, a large batch of files are modified on/etc/profile and then on source. The teacher also talked about modifying a file under root (in ThizLinuxinux ). However, I still enter the complete path. Fear.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service