für XML-Datei Parsing I JAXB verwenden aber nach der Kompilierung folgende FehlerJAXBException: kein Paketname wird
gemeldetjavax.xml.bind.JAXBException: No package name is given
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at searchAlgo.Question.<init>(Question.java:16)
Code wird unter
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
public class Question {
//String question = new String() ;
String s = new String();
Question()
{
try{
File file = new File("C:\\Users\\Username\\Documents\\levels.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(s);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
String string = (String) jaxbUnmarshaller.unmarshal(file);
System.out.println(string);
}
catch(JAXBException e){
e.printStackTrace();
}
}}
gegeben brauche ich JAXB Stecker installieren -im? Ich benutze jdk 1.8.0_91 und Eclipse Mars
Diese Frage wurde zuvor gestellt. https://stackoverflow.com/questions/20273355/why-does-jaxbcontext-need-to-be-told-spezifically-about-a-class-that-ist-ready – user8271644