0
我想在java應用程序中使用我的凸輪,但我在這裏得到一些錯誤是我的代碼。其簡單的有人告訴我什麼是錯我的代碼:在java網絡攝像頭錯誤
import java.util.Vector;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFrame;
public class Main extends JFrame {
public Main(){
super("Jcam");
try {
Vector v = CaptureDeviceManager.getDeviceList(null);
CaptureDeviceInfo cam = null;
for(int i=0;i<v.size();i++)
{
CaptureDeviceInfo dev = (CaptureDeviceInfo) v.elementAt(i);
if(dev.getName().startsWith("vfw"))
{
cam = dev;
break;
}
System.out.println(dev.getName());
}
if (cam == null){ System.exit(0); }
MediaLocator ml = cam.getLocator();
Player p = Manager.createRealizedPlayer(ml);
add(p.getVisualComponent());
p.start();
} catch (Exception e) {
}
setSize(700, 700);
setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
new Main();
}
,這裏是日誌
Exception in thread "VFW Request Thread" java.lang.UnsatisfiedLinkError: JMFSecurityManager: java.lang.UnsatisfiedLinkError: no jmvfw in java.library.path
at com.sun.media.JMFSecurityManager.loadLibrary(JMFSecurityManager.java:206)
at com.sun.media.protocol.vfw.VFWCapture.<clinit>(VFWCapture.java:19)
at com.sun.media.protocol.vfw.VFWSourceStream.doConnect(VFWSourceStream.java:241)
at com.sun.media.protocol.vfw.VFWSourceStream.run(VFWSourceStream.java:763)
at java.lang.Thread.run(Unknown Source)
你可能會錯過庫路徑上所需的本地庫。 – asgs
我不這麼認爲。因爲我已經將jmf.jar添加到我的項目中 –
向項目中添加庫與爲Java實例設置庫路徑不同。請參閱[如何設置-java-library-path-from-eclipse](http://stackoverflow.com/questions/957700/how-to-set-the-java-library-path-from-eclipse ) 更多細節。 – asgs