【发布时间】:2015-08-13 08:54:10
【问题描述】:
我在 Ubuntu 12.04 的 netbeans 上尝试使用 java 中的模板进行测试时收到此错误。根据代码下方的错误信息,我需要从这里做什么。它是说我应该做些什么来解决我的问题。
这是我的代码
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
public class again {
public static void main(String[] args) {
Mat m=Highgui.imread("/root/image.png",Highgui.CV_LOAD_IMAGE_OLOR);
}
}
运行: 线程“主”java.lang.UnsatisfiedLinkError 中的异常:org.opencv.highgui.Highgui.imread_0(Ljava/lang/String;I)J 在 org.opencv.highgui.Highgui.imread_0(本机方法) 在 org.opencv.highgui.Highgui.imread(Highgui.java:296) 在again.main(again.java:22) Java 结果:1
更新:我更改了代码,它说它编译成功,但我仍然无法让它在窗口中显示图像。我还有另一个类应该是“互连的”来显示图片,但它没有。
public class again {
public static void main(String[] args) {
}
Mat m=Highgui.imread("/root/image.png",Highgui.CV_LOAD_IMAGE_COLOR);
LoadImage loadImage= new LoadImage("/root/image.png",m);
}
这是另一个类
import java.awt.*;
import javax.swing.*;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class LoadImage extends JFrame {
public static void main(String[] args) {
}
public LoadImage(String imgStr,Mat m)
{
Highgui.imwrite(imgStr,m);
JFrame frame = new JFrame("My GUI");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(true);
frame.setLocationRelativeTo(null);
// Inserts the image icon
ImageIcon image = new ImageIcon(imgStr);
frame.setSize(image.getIconWidth()+10,image.getIconHeight()+35);
// Draw the Image data into the BufferedImage
JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
frame.getContentPane().add(label1);
frame.validate();
frame.setVisible(true);}
}
抱歉,我无法正确安装它,但我无法找出我正在使用的 java 版本,或者更糟糕的是我可能没有安装 java
root@ubuntu:/# sudo java –version
Exception in thread "main" java.lang.NoClassDefFoundError: –version
Caused by: java.lang.ClassNotFoundException: –version
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: –version. Program will exit.
【问题讨论】: