The class file compiled by the command line generates UnsupportedClassVersionError on the Myeclipse server. The myeclipse command line
Suppose we have compiled the java file into a class file in the command line. Then, we can see that the following information appears on the server console.
The line we care about is
Severe: Exception invoking periodic operation:
Java. lang. UnsupportedClassVersionError: FirstServlet2: unsupportedmajor. minor version 52.0 (unable to load class FirstServlet2)
In this case, an error occurs when I access the files that I can access in the folder through a browser.
That is to say, I have stored the class file path // localhost/linshaolong, that is, all the files in the outer folder of my WEB-INF cannot be accessed through a browser, the preliminary conclusion is that the class file is added, and the entire folder is not configured in the server.
Then let's look back at the error of java. lang. UnsupportedClassVersionError, which roughly means the unsupported calss file version error. Check the errors caused by the attempt to run the java class file compiled by the JDK of a later version on the JVM of a later version.
Through java-version, I found that the jdk version of my command line is 1.8.0-65.
The JDK version of my myeclipse configuration server is jdk7. we can see that the deployment is unsuccessful because the jdk version running on the server is too low.
,
There are three solutions:
Method 1: Find a version of Myeclipse above jdk8 and download it again (idle)
Method 2: Change the compiling environment of Myeclipse and the jdk environment of the server to 1.8.
Click add and select Directory in the pop-up interface and select the jdk version when you installed the java environment. In this way, the version of the server running is the same as the jdk version of the command line. OK.
In this case, you can re-open the server and deploy the class file jdk1.8.0 _ 65. No problem with access.
If you are idle, you can search for installed JREs in the windows-Preferences search box.
Configure the jre environment to jdk1.8.0 _ 65
In this way, the class file compiled with Myeclipse is also jdk1.8.0 _ 65.
Method 3: Compile the java file in Myeclipse.
That is to say, drag the java file to the project, save it, and find the corresponding folder that stores the class file. (If the java file with manual code is the default package at the beginning, save it in the default package of the Myeclipse project .)
Then put the compiled class file back into the classes folder of the original WEB-INF. Configure the web. xml Path.
Then we can see that the task can be run.
Well. That's almost all... Come and try again...