Apache Jena - java.lang.UnsupportedClassVersionError:com / hp / hpl / jena / rdf / model / ModelFactory

时间:2014-09-11 08:32:39

标签: java apache stream jena

我正在尝试本教程,并希望运行以下代码:

public class test extends Object {
    // some definitions
    static String personURI    = "http://somewhere/JohnSmith";
    static String fullName     = "John Smith";

    public static void main (String args[]) {
        // create an empty model
        Model model = ModelFactory.createDefaultModel();

        // create the resource
        Resource johnSmith = model.createResource(personURI);

        // add the property
        johnSmith.addProperty(VCARD.FN, fullName);
    }

}

这些是我的项目设置:

enter image description here

但是,我得到了:

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/hp/hpl/jena/rdf/model/ModelFactory : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.dataGenerator.test.test.main(test.java:15)


Any recommendations what I am doing wrong?

I appreciate your answer!

1 个答案:

答案 0 :(得分:3)

编译时的java版本高于运行时的java版本。主要版本51是Java 7,确保您的运行时环境使用此版本作为最低版本