Hello I have a simple JAXB example class. But while I try to generate an xsd schema to it I am getting a folowing exception
`Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/jpt/jaxb/core/schemagen/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
The steps I came to this error are: Simply created a JAXB project in eclipse Implemented the class below
`package com.prods;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "product")
public class Product {
@XmlAttribute
protected int id; // необязательный
protected String name; // обов’язковий, не пустий рядок
protected double price; // >= 0
protected String descr; // необязательный
protected String[] categories; // необов’язковий, якщо присутній, то не
protected char[] chars;// обов’язковий, можуть бути різними
}
`
T
hen I try to add the xsd schema I am getting this exception. For a target I use java 1.7 mac os X JAXB v2.1. How can I fix this? If I rty to run the project adding main function to the class it is running normaly. The problem accurs when you try to add an xsd schema buy creating it with eclipse. Version of eclise is 2022-12 for Java enterprise.
I tryed to change the Java version I am running to JDK 19 it didn't help ofcors.
CodePudding user response:
Unsupported major.minor version 52.0
This means Java8, as mentionned here: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
Basically, it means you're compiling with a more recent version of java than what your code is running on. Check the JDK used to build, not only the running one.
CodePudding user response:
Hello I had a same problem recently on the latest eclipse version to 2022.12 that is. Problem is actually comming not from your java application everythin fine with that but from eclipse itself during the schema generation. It is using some deprecated function for working with xml and JRE wich it is running on not a target JRE is not supporting them. But if you try to run eclipse on JRE 1.7 eclipse won't run because of missing dependencies. Only solution for me was to install JRE 1.6 and eclipse Indigo v3.7 and do the task there