java.lang.ClassLoader.loadClass 中的错误(来源不明)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18946744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error in java.lang.ClassLoader.loadClass(Unknown Source)
提问by Francesco Sgaramella
For my thesis I am trying to handle some things with pictures and one of the steps to complete it is to find corners in a picture. After some surfing I found that it can be implemented with Moravec's algorithm for corner detection. By luck, I found the Moravec's algorithm already implemented by JFeatureLib at this link: https://code.google.com/p/jfeaturelib/source/browse/src/main/java/de/lmu/ifi/dbs/jfeaturelib/pointDetector/Moravec.java?r=8d96a8fa9a43a0ec7e7084b40169be56bddd6f36
对于我的论文,我试图用图片处理一些事情,完成它的步骤之一是在图片中找到角落。经过一番冲浪,我发现它可以用 Moravec 的算法实现角点检测。幸运的是,我发现 JFeatureLib 已经在此链接中实现了 Moravec 算法:https: //code.google.com/p/jfeaturelib/source/browse/src/main/java/de/lmu/ifi/dbs/jfeaturelib/ pointDetector/Moravec.java?r=8d96a8fa9a43a0ec7e7084b40169be56bddd6f36
(Of course I imported the jar file given from JFeatureLib in the build path of Eclipse) So I used the code at the link in my project, and wrote some code to call it. Here is the code in which I create a Frame, open the picture and call the Moravec algorithm at that link:
(当然我在Eclipse的构建路径中导入了JFeatureLib给出的jar文件)所以我在我的项目中使用了链接处的代码,并编写了一些代码来调用它。这是我在其中创建框架、打开图片并在该链接上调用 Moravec 算法的代码:
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class Compare{
public Compare(){
JFrame frame = new JFrame("Find corners in picture");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = (JPanel)frame.getContentPane();
JLabel label = new JLabel();
label.setIcon(new ImageIcon("house.jpg"));
panel.add(label);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
}
public static void main (String[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new Compare();
}
});
Moravec picture = new Moravec();
}
}
The point is that it returns an error on the line
重点是它在行上返回一个错误
Moravec picture = new Moravec();
the error it's like this:
错误是这样的:
Exception in thread "main" java.lang.UnsupportedClassVersionError: de/lmu/ifi/dbs/jfeaturelib/pointDetector/PointDetector : 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##代码##0(Unknown Source)
at java.net.URLClassLoader.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 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##代码##0(Unknown Source)
at java.net.URLClassLoader.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 Compare.main(Compare.java:32)
Could you please give me some advices? Thanks a lot!
你能给我一些建议吗?非常感谢!
采纳答案by Enno Shioji
Unsupported major.minor version 51.0
You are trying to run a jar compiled with a newer Java version in an older Java version. The message suggest de/lmu/ifi/dbs/jfeaturelib/pointDetector/PointDetector
was compiled using JDK7, but you are trying to run it with an older version (I'm guessing Java 6).
Unsupported major.minor version 51.0
您正在尝试在较旧的 Java 版本中运行使用较新的 Java 版本编译的 jar。消息建议de/lmu/ifi/dbs/jfeaturelib/pointDetector/PointDetector
是使用 JDK7 编译的,但您正在尝试使用旧版本(我猜是 Java 6)运行它。
Execute java -version
and see if this the case. If so, find the JDK7 on your system and use that instead to run your program.
执行java -version
并查看是否是这种情况。如果是这样,请在您的系统上找到 JDK7 并使用它来运行您的程序。